ApiSandbox 'continue' button breaks on second use
Closed, ResolvedPublic

Description

Use the ApiSandbox to make a list request with a continue param, e.g.:

https://en.wikipedia.beta.wmflabs.org/wiki/Special:ApiSandbox#action=query&format=json&list=alllinks&allimit=5

Press "make request"; see that a reasonable set of data comes back with a alcontinue parameter set.

Press "continue"; see that a new reasonable set of data comes back, with a new alcontinue parameter set.

Press "continue"; see that you get a form entry error ("Some fields are invalid") rather than the data you wanted, and the contents of the form have been blanked.

Additionally in the JS console I see:

VM208:411 Uncaught TypeError: Cannot read properties of null (reading 'data')
    at OoUiDropdownWidget.<anonymous> (<anonymous>:234:945)
    at OO.EventEmitter.emit (<anonymous>:411:656)
    at OO.ui.SelectWidget.selectItem (load.php?lang=en&modules=jquery%2Coojs-ui-core%2Coojs-ui-widgets%7Coojs-ui.styles.icons-editing-advanced&skin=vector&version=6pux1:241:165)
    at OoUiDropdownWidget.setApiValue (<anonymous>:226:228)
    at OoUiDropdownWidget.<anonymous> (<anonymous>:261:879)
    at Function.each (load.php?lang=en&modules=jquery%2Coojs-ui-core%2Coojs-ui-widgets%7Coojs-ui.styles.icons-editing-advanced&skin=vector&version=6pux1:5:356)
    at ApiSandbox.PageLayout.loadQueryParams (<anonymous>:261:753)
    at Object.updateUI (<anonymous>:239:841)
    at Object.sendRequest (<anonymous>:241:280)
    at <anonymous>:246:226

Event Timeline

Finally got sick of seeing this and took 20 minutes to look into it (and then found this existing task about it). Looks like the problem was b33524cc93ee3e1a31c045f3c2f934ddaf9c186d, which incorrectly changed the global-ish baseRequestParams into a local variable so it's no longer preserved as intended across calls.

Change 826540 had a related patch set uploaded (by Seb35; author: Seb35):

[mediawiki/core@master] Fix continuations on second use in ApiSandbox

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

I was bitten by this bug and found this issue. Here it is the fix as described by @Anomie (I added Co-Authored-by given it is the direct fix you proposed).

Change 826540 merged by jenkins-bot:

[mediawiki/core@master] Fix continuations on second use in ApiSandbox

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

matmarex assigned this task to Seb35.
matmarex subscribed.

Thank you both!