Page MenuHomePhabricator

Breaking change in parse API: level was string, is now int
Closed, ResolvedPublicBUG REPORT

Description

Unfortunately, I don't have an exact URL to reproduce this, but see https://en.wikipedia.org/wiki/Wikipedia_talk:Sockpuppet_investigations/SPI/Clerks#Spi-helper_problems. The gist is that action=parse used to return "level" as a string, and now it's an integer. This broke client-side code which uses that API.

Old-style result:

{
    "toclevel": 2,
    "level": "3",
    "line": "09 March 2022",
    "number": "1.1",
    "index": "1",
    "fromtitle": "Wikipedia:Sockpuppet_investigations/Yeu_aga_maj",
    "byteoffset": 98,
    "anchor": "09_March_2022"
}

New-style result:

{
    "toclevel": 2,
    "level": 3,
    "line": "18 March 2022",
    "number": "1.1",
    "index": "1",
    "fromtitle": "Wikipedia:Sockpuppet_investigations/RoySmith-Mobile",
    "byteoffset": 88,
    "anchor": "18_March_2022"
}

This appears to be due to this change which was apparently rolled out yesterday. We've patched around the problem (https://github.com/GeneralNotability/spihelper/pull/119) but need clarification if this was an intentional change, and/or if it's going to be rolled back.

Event Timeline

See current behavior with int level values at this API result. Contrast with an apparent cached result that has str level values here (picking an arbitrary page unlikely to be edited anytime soon).

@matmarex pointed me to change 768247 by @Umherirrender as the possible cause of this. Was this an intended consequence of that change? It's hard to say yet whether spihelper was the only script relying on these values being strs, but my guess is there's probably at least one other out there. (spihelper now works with these values as strs or ints, so any further changes in that regard shouldn't be breaking for it.)

taavi added subscribers: Zabe, taavi.

Tagging MW-1.38-release to make sure any fixes if any will be backported before release. Additionally cc @Zabe as the +2er of that patch.

Change 771950 had a related patch set uploaded (by Zabe; author: Zabe):

[mediawiki/core@master] parser: change 'level' in parse api back to string

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

Change 771950 merged by jenkins-bot:

[mediawiki/core@master] parser: change 'level' in parse api back to string

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

Change 771911 had a related patch set uploaded (by Zabe; author: Zabe):

[mediawiki/core@REL1_38] parser: change 'level' in parse api back to string

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

Change 771911 merged by jenkins-bot:

[mediawiki/core@REL1_38] parser: change 'level' in parse api back to string

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

Zabe closed this task as Resolved.EditedMar 19 2022, 1:53 PM
Zabe claimed this task.

Thanks for the report. It was not an intentional change. Or rather, it should have always been an integer, but we will go back to strings with next weeks train to keep b/c.

Due to Trainsperiment it makes no real sence to backport the fix. It should be rolled out on monday.