Last modified: 2014-03-06 18:21:32 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T52511, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 50511 - TemplateData: Get better error messages for JSON syntax errors
TemplateData: Get better error messages for JSON syntax errors
Status: ASSIGNED
Product: MediaWiki extensions
Classification: Unclassified
TemplateData (Other open bugs)
master
All All
: Low enhancement (vote)
: ---
Assigned To: Editing team bugs – take if you're interested!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-07-01 18:41 UTC by Oliver Keyes
Modified: 2014-03-06 18:21 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Oliver Keyes 2013-07-01 18:41:44 UTC
Enhancement request for more informative error messages - as simple as "JSON error on line foo" instead of "JSON error"
Comment 1 Krinkle 2013-07-01 20:53:12 UTC
It is in my opinion not feasible to get line numbers because we use a native PHP extension to parse the JSON.

If the JSON syntax itself is invalid, there is nothing we can do. Best case scenario the parser gives the type of error ("Unexpected comma", "Expected closing curly brace" etc.) but a line number is unlikely.

Once the JSON is parsed, the TemplateData validation itself (e.g. sets referring to existing parameters) we have full control over and gives pretty informative errors with the full path to the property.

> Unexpected property "params.user.blabla".
> Property "params.timestamp.description" is expected to be of type "string|object".

etc.
Comment 2 James Forrester 2013-07-02 03:14:53 UTC
Presumably this could be done if bug 50169 was implemented, though. :-)
Comment 3 Bill Skaggs 2013-07-02 14:23:05 UTC
Displaying the contents of the line at which an error is detected, with a few lines around it for context, would be almost as useful as a line number.  Of course the actual error can be a long way off from the point at which a syntax error is detected, but the information would still be helpful.  Adding information about the type of error would make it even better.  Really any information at all about the nature of the error would be an improvement.
Comment 4 NicoV 2013-07-22 15:15:54 UTC
For the moment, you can use TemplateDataEditor to be able to create the <templatedata/> without editing any real JSON.

http://en.wikipedia.org/wiki/User:NicoV/TemplateDataEditor
Comment 5 Krinkle 2013-10-06 17:07:02 UTC
(In reply to comment #2)
> Presumably this could be done if bug 50169 was implemented, though. :-)

Well, in case of bug 50169 (VisualEditor plugin for TemplateData) there would never be a syntax error in the JSON because the user wouldn't be editing it directly. They'd be using a form-like interface to interact with it (VE would generate the JSON which is always valid).

However if the VE plugin would have a raw mode to edit the JSON (e.g. using an Ace surface like Extension:CodeEditor does), we could use its JSHint integration to get inline errors by line/char highlighting (e.g. like in Sublime).

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links