Page MenuHomePhabricator

Query action on API returns the rvcontinue value that point to itself causes infinite loop
Closed, ResolvedPublic

Description

Hello!

Description: While working on a query action on Wikipedia (enwiki) API to get revision metadata, a particular query was found to return rvcontinue value that points to itself, this bug may introduce undesired infinite-loop behavior for certain programs.

Query string: https://en.wikipedia.org/w/api.php?action=query&prop=revisions&format=json&formatversion=2&maxlag=5&rvdir=newer&rvlimit=30&rvprop=ids|flags|timestamp|oresscores|size|sha1|tags|user|userid|comment|parsedcomment&titles=Zika_virus&rvcontinue=20160128052605|702062831

Returned result: {"continue":{"rvcontinue":"20160128052605|702062831","continue":"||"},"query":{"normalized":[{"fromencoded":false,"from":"Zika_virus","to":"Zika virus"}],"pages":[{"pageid":24831215,"ns":0,"title":"Zika virus"}]}}

Event Timeline

Anomie subscribed.

It appears to have something to do with MediaWiki-extensions-ORES, since removing oresscores from rvprop causes it to function as expected.

What's going on there is that ORES can't score https://en.wikipedia.org/w/index.php?title=Zika_virus&oldid=702062831 because it has been revision-deleted, but it doesn't realize that so it tries to score it, fails, and then decides that must be because it submitted a job for async scoring and so returns a continuation for that revision.

Assuming that whatever is doing the scoring doesn't return transient errors as 'error', one solution would be to set $scores[$revision] = [] in the cache's error callback so it returns an empty score set instead of thinking it needs to retry it on a subsequent query. It might also be nice to include appropriate information in the API output there too, i.e. pass $module in from the caller and use $module->addWarning().

I am not an expert by any means, but what we need to do is ensure check for rev del (use the api to check if rev del status is true) if so then cancel the score and return an error stating the target revison has been deleted.

Change 381631 had a related patch set uploaded (by Ladsgroup; owner: Amir Sarabadani):
[mediawiki/extensions/ORES@master] Return empty result when it's errored

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

Change 381631 merged by jenkins-bot:
[mediawiki/extensions/ORES@master] Return empty result when it's errored

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

This fix should be deployed to WMF wikis with 1.31.0-wmf.2, see https://www.mediawiki.org/wiki/MediaWiki_1.31/Roadmap for the schedule.