Page MenuHomePhabricator

parsoid crate: "JSON error: data did not match any variant of untagged enum TransclusionPart"
Closed, ResolvedPublic

Description

Trying to call code.filter_templates()? on https://en.wikipedia.org/api/rest_v1/page/html/Talk%3ASignaling_of_the_New_York_City_Subway gives:

Error: JSON error: data did not match any variant of untagged enum TransclusionPart at line 1 column 811

This is caused by the stray {{{2|}}} in <small>&mdash;''The preceding [[Wikipedia:Sign your posts on talk pages|unsigned]] comment was added by'' [[User:Rock nj|Rock nj]] ([[User talk:Rock nj|talk]]&nbsp;&bull;&nbsp;[[Special:Contributions/Rock nj|contribs]]) {{{2|}}}.</small><!--Inserted with Template:Unsigned-->

Documentation for this is actually at https://www.mediawiki.org/wiki/Specs/HTML/2.7.0#Parameter_Substitution_at_the_top-level which says "This section is only present for the sake of completeness. Unexpanded parameter markup is unlikely to be useful in top-level content, and if found, it is either a draft, syntax error, or a copy-paste without being fixed up." - obviously it's an error but we shouldn't be crashing on it.

Details

TitleReferenceAuthorSource BranchDest Branch
Handle "templatearg" in a multi-part templaterepos/mwbot-rs/mwbot!26legoktmtemplateargmain
Customize query in GitLab

Event Timeline

Legoktm triaged this task as High priority.Feb 23 2023, 6:04 AM
Legoktm created this task.

The JSON structure is:

Object {
    "templatearg": Object {
        "i": Number(1),
        "params": Object {
            "1": Object {
                "wt": String(""),
            },
        },
        "target": Object {
            "wt": String("2"),
        },
    },
},

I think this merits a backport to the 0.7.x stable series.

Merged and released in parsoid 0.7.6 and 0.8.0-alpha.5.