Page MenuHomePhabricator

feature request: `toomanyvalues` error: include the parameter name in a separate field
Closed, ResolvedPublic

Description

Currently if someone sends a request with too many values, e.g.:

{'titles': '0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50', 'rvprop': 'ids', 'prop': 'revisions', 'action': 'query', 'format': 'json', 'formatversion': '2', 'errorformat': 'plaintext', 'maxlag': 5}

will get:

{'errors': [{'code': 'toomanyvalues', 'text': 'Too many values supplied for parameter "titles". The limit is 50.', 'data': {'limit': 50, 'lowlimit': 50, 'highlimit': 500}, 'module': 'query'}], 'docref': 'See https://en.wikipedia.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes.', 'servedby': 'mw1383'}

or with action spamblacklist:

{'action': 'spamblacklist', 'url': '0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50', 'format': 'json', 'formatversion': '2', 'errorformat': 'plaintext', 'maxlag': 5}

will get:

{'code': 'toomanyvalues', 'text': 'Too many values supplied for parameter "url". The limit is 50.', 'data': {'limit': 50, 'lowlimit': 50, 'highlimit': 500}, 'module': 'spamblacklist'}

Some clients are smart enough to break the parameter before sending a request, but let's say this is not one of those clients, or the client does not yet know the applicable limit for the current user.

It would be helpful if the parameter which is violating the limit was included in a separate field in the error (or its data?) so that the client can automatically handle the error and break the request into several parts.

Currently the parameter name is included in the 'text' field which retrieving it requires parsing the text and also the format is language/version dependant which makes the matter more complicated.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 926659 had a related patch set uploaded (by SD0001; author: SD0001):

[mediawiki/core@master] api: include parameter name in error details for toomanyvalues error

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

Change 926659 merged by jenkins-bot:

[mediawiki/core@master] api: include parameter name in error details for toomanyvalues error

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