Page MenuHomePhabricator

/page/{title}/links/media returns 500 error when more than 100 media files present
Closed, ResolvedPublicBUG REPORT

Description

/page/{title}/links/media returns 500 error when more than 100 media files present, but as per documentation at https://www.mediawiki.org/wiki/API:REST_API/Reference#Get_files_on_page, 500 error is supposed to happen if the page has more than 500 media files.

The following examples illustrate the issue:
https://en.wikipedia.org/w/rest.php/v1/page/Barcelona/links/media
https://en.wikipedia.org/w/rest.php/v1/page/India/links/media

{"messageTranslations":{"en":"Too many media links found on title India (100 allowed)"},"httpCode":500,"httpReason":"Internal Server Error"}

Event Timeline

DannyS712 changed the subtype of this task from "Task" to "Bug Report".

Since 100 is the limit defined in the code, I've updated the documentation accordingly.

500 is clearly not a correct status code. 500 indicates an unknown server error, here it's a very much a known error - we were lazy and didn't implement pagination.

If we want to continue being lazy and not adding pagination, we can maybe at least return 501 Not implemented, it would be much less confusing.

If we want to continue being lazy and not adding pagination, we can maybe at least return 501 Not implemented, it would be much less confusing.

Indeed. Or 507 (insufficient memory).

Any 50x error will result in this task being reported and/or re-opened as that indicates a fault in a service we run. If users aren't meant to ask for this information, or we refuse to support providing it, then that seems like a client error, and thus 40x, and thus cacheable by the CDN and not a risk to backend floods.

404 would be fairly generic, but an improvement over the status quo and mitigate the raised error levels and production risk, and thus resolve this task.

Change 959065 had a related patch set uploaded (by Fgoodwin; author: Fgoodwin):

[mediawiki/core@master] Change error code for rest-media-too-many-links

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

Change 961472 had a related patch set uploaded (by Fgoodwin; author: Fgoodwin):

[mediawiki/core@master] Adds test

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

Change 961472 merged by jenkins-bot:

[mediawiki/core@master] Change error code for rest-media-too-many-links

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

Change 959065 abandoned by BPirkle:

[mediawiki/core@master] Change error code for rest-media-too-many-links

Reason:

Abandoned in favor of https://gerrit.wikimedia.org/r/c/mediawiki/core/+/961472

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

BPirkle subscribed.

Per discussion in code review, we went with a 400 error if the limit is exceeded.

Marking this as resolved. There is still a TODO in the code for adding pagination, but that change, if we ever do it, can be handled under a separate task.