Page MenuHomePhabricator

Validate parameters in maps to ensure they're valid template data parameters.
Open, Needs TriagePublic

Description

If the parameters are invalid template data parameters (i.e. not defined as a param earlier in the template data), this thows a fatal error on saving the template data.

We should notify the user if there are any invalid parameters in the template data and tell them which parameter it is.

i.e.

Invalid parameter "cats" for property "maps.citoid.forumTitle".

An even nicer UI would be to highlight valid params in green and invalid params in red.

Event Timeline

Mvolz updated the task description. (Show Details)
Mvolz updated the task description. (Show Details)
Mvolz updated the task description. (Show Details)
Mvolz updated the task description. (Show Details)

Removing the GSoC tag, since this is follow-up work.

Change 749693 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/TemplateData@master] Split validation and HTML formatting into separate services

https://gerrit.wikimedia.org/r/749693

Change 749698 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/TemplateData@master] Split validation into some smaller steps

https://gerrit.wikimedia.org/r/749698

Backend validation is done ever since the maps feature was implemented in 2014, see https://gerrit.wikimedia.org/r/167389. Two of the three possible error messages (there are 3 possible nesting levels) missed some details. We fixed this a few months ago, see https://gerrit.wikimedia.org/r/715307.

I tested the example from the task description and this is what it currently says:

Invalid parameter "cats" for property "maps.citoid.forumTitle".

The idea to highlighting such errors earlier in the UI might refer to a few different things:

  1. As of now, editing maps in the TemplateData dialog is done by manually editing each map's JSON. There is already validation in place that blocks the "Done" button when the JSON is invalid. This step could also verify the parameter names used in the map. However:
    • This duplicates the backend validation.
    • What if a user want's to document a parameter after mentioning it in a map? While this is probably rare, I think it's a valid workflow.
    • Realtime validation also means we would constantly show an error while the user types. I think this is distracting, probably even misleading.
    • Users that know what maps are and how they need to be structured probably know what they are doing, and are fine with getting errors later.
  2. T260788 suggests to add syntax highlighting to the dialog. This might make it possible to highlight errors in place.
  3. The same could be done in the wikitext editor via the MediaWiki-extensions-CodeMirror syntax highlighter. (Probably not a good idea, but not impossible.)

When I added this to our sprint I assumed it would be about the backend validation. But it's about the dialog.

I suggest to close this as declined based on the arguments above.

Change 749693 merged by jenkins-bot:

[mediawiki/extensions/TemplateData@master] Split validation and HTML formatting into separate services

https://gerrit.wikimedia.org/r/749693

Change 749698 merged by jenkins-bot:

[mediawiki/extensions/TemplateData@master] Split validation into some smaller steps

https://gerrit.wikimedia.org/r/749698