Page MenuHomePhabricator

Api returns continue parameters even though there are no more pages in the query results.
Closed, InvalidPublic

Description

I have 5 (titled 1 through 5) watched pages and I'm querying them on the Watchlist page (mobile). The first two pages are already shown on page load. I'm trying to get the next 2 pages with this query:

http://127.0.0.1:8080/w/api.php?action=query&prop=pageimages%7Cinfo&piprop=thumbnail&pithumbsize=80&format=json&generator=watchlistraw&gwrnamespace=0&gwrlimit=3&continue=&gwrfromtitle=2

Which returns

{"continue":{"picontinue":5,"continue":"||info"},"query":{"pages":{"4":{"pageid":4,"ns":0,"title":"2","contentmodel":"wikitext","pagelanguage":"en","touched":"2015-08-06T21:21:25Z","lastrevid":10,"length":13},"5":{"pageid":5,"ns":0,"title":"3","contentmodel":"wikitext","pagelanguage":"en","touched":"2015-08-06T18:53:22Z","lastrevid":6,"length":1,"new":""},"6":{"pageid":6,"ns":0,"title":"4","contentmodel":"wikitext","pagelanguage":"en","touched":"2015-08-06T18:53:32Z","lastrevid":7,"length":6,"new":""}}}}

Using the continue info from the above response throws the following error message:

{"error":{"code":"pi_badcontinue","info":"Invalid continue param. You should pass the original value returned by the previous query","*":"See http://127.0.0.1:8080/w/api.php for API usage"}}

So rather than using the continue parameters from above, I'm querying the next 2 pages with this url:

http://127.0.0.1:8080/w/api.php?action=query&prop=pageimages%7Cinfo&piprop=thumbnail&pithumbsize=80&format=json&generator=watchlistraw&gwrnamespace=0&gwrlimit=2&continue=&gwrfromtitle=4

(I know that the last title the API returned is 4.)

The response I get is this:

{"continue":{"picontinue":7,"continue":"||info"},"query":{"pages":{"6":{"pageid":6,"ns":0,"title":"4","contentmodel":"wikitext","pagelanguage":"en","touched":"2015-08-06T18:53:32Z","lastrevid":7,"length":6,"new":""},"7":{"pageid":7,"ns":0,"title":"5","contentmodel":"wikitext","pagelanguage":"en","touched":"2015-08-06T18:53:44Z","lastrevid":8,"length":6,"new":""}}}}

Notices still that the continue parameters are set even though the page 5 is the last page in my watchlist. This is the bug I think.

Just to see what I get next, I ping the following URL:

http://127.0.0.1:8080/w/api.php?action=query&prop=pageimages%7Cinfo&piprop=thumbnail&pithumbsize=80&format=json&generator=watchlistraw&gwrnamespace=0&gwrlimit=2&continue=&gwrfromtitle=5

Now the continue parameter is gone and I get only 1 result (which is correct because there are no more pages after page 5).

To sum it up, the continue parameter must be empty in the previous response (not the last response).

Event Timeline

bmansurov raised the priority of this task from to Needs Triage.
bmansurov updated the task description. (Show Details)
bmansurov added a project: PageImages.
bmansurov subscribed.
Jdlrobson set Security to None.
Jdlrobson added subscribers: Anomie, Jdlrobson.

Given this is continuation I suspect the bug is in core or down to invalid use of parameters. Am hoping @Anomie or someone else can identify which.

As a start, please provide all query URLs, rather than just "Using the continue info from the above response".

It would also be helpful to post the output of http://127.0.0.1:8080/w/api.php?action=query&format=json&generator=watchlistraw&gwrnamespace=0&gwrlimit=max&continue= for context.

Notices still that the continue parameters are set even though the page 5 is the last page in my watchlist. This is the bug I think.

No, that's not "the" bug. The response you're getting contains two pages, "4" and "5". The response includes the (nonexistent) page image for page "4", and the continuation is to get the page image for page "5".

bmansurov claimed this task.

Sorry, I can't remember the details but the problem got resolved by adding some missing query parameters.