Page MenuHomePhabricator

EventLogging extension doesn't indicate which lines contain invalid JSON
Closed, ResolvedPublic

Description

When you try to save invalid JSON into a page in the Schema namespace on Meta-Wiki (e.g., https://meta.wikimedia.org/wiki/Schema:Sandbox), an error message appears:


Invalid JSON. The content of this page must be valid JSON. Please check your syntax.

This error message does not currently include on which line(s) there's an alleged error, though. It'd be nice if it listed the lines containing errors or highlighted the offending lines in red or both or something. Maybe activating the CodeEditor extension on this namespace (bug 42561) would help mitigate the issue of invalid JSON being submitted, but a more direct error message from this extension would be nice.


Version: unspecified
Severity: normal

Details

Reference
bz42564

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 1:07 AM
bzimport set Reference to bz42564.
bzimport added a subscriber: Unknown Object (MLST).

I'm gonna go ahead and mark this bug as easy. If that's inaccurate, feel free to remove the keyword.

Linebreaks in JSON aren't significant, and the content model treats them as presentational artifacts (for example, by coercing all edits into a consistent format). So associating an error with a particular line isn't quite right. It might be easiest to simply indicate the specific character on which parsing finally choked, including the line it appeared on. This probably involves modifying the FormatJson class in core, but you're right -- I don't think it'll be a difficult change to make.

[moving from MediaWiki extensions to Analytics product - see bug 61946]

ori claimed this task.

EventLogging now uses the CodeEditor extension to provide an interface for editing JSON schemas. The CodeEditor extension marks the offending line and provides a human-readable validation error.

pasted_file (222×792 px, 34 KB)