Page MenuHomePhabricator

⏳ [Create error] Too many requests
Closed, ResolvedPublic5 Estimated Story Points

Description

Acceptance criteria:

  • User behaviour it should apply to: Rate limited edits and Temp user creation throttling
  • HTTP status code: 429
  • Error code: request-limit-reached
  • Error message: Exceeded the limit of actions that can be performed in a given span of time
  • Error context: { "reason": "{reason-code}" } (where reason-code is one of 'rate-limit-reached', 'temp-account-creation-limit-reached')

OLDER
Corresponding action API responses
Rate limiting:

{
    "error": {
        "code": "failed-save",
        "info": "The save has failed.",
        "messages": [
            {
                "name": "wikibase-api-failed-save",
                "parameters": [],
                "html": {
                    "*": "The save has failed."
                }
            },
            {
                "name": "actionthrottledtext",
                "parameters": [],
                "html": {
                    "*": "As an anti-abuse measure, you are limited from performing this action too many times in a short space of time, and you have exceeded this limit.\nPlease try again in a few minutes."
                }
            }
        ],
        "*": "See http://default.mediawiki.mwdd.localhost:8080/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/> for notice of API deprecations and breaking changes."
    },
    "servedby": "2ccec9f2adab"
}

Temp user creation throttling:

{
    "error": {
        "code": "failed-save",
        "info": "The save has failed.",
        "messages": [
            {
                "name": "wikibase-api-failed-save",
                "parameters": [],
                "html": "The save has failed."
            },
            {
                "name": "acct_creation_throttle_hit",
                "parameters": [
                    3,
                    {
                        "duration": 10000
                    }
                ],
                "html": "Visitors to this wiki using your IP address have created 3 accounts in the last 2 hours, 46 minutes and 40 seconds, which is the maximum allowed in this time period.\nAs a result, visitors using this IP address cannot create any more accounts at the moment."
            }
        ],
        "docref": "See http://default.mediawiki.mwdd.localhost:8080/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/> for notice of API deprecations and breaking changes."
    },
    "servedby": "2ccec9f2adab"
}

Event Timeline

Ifrahkhanyaree_WMDE renamed this task from [Generalised error] Too many requests to [Create error] Too many requests .Jul 4 2024, 10:27 AM

We think these should be two different errors:

  • too many edit requests
  • too many temp user requests

The latter can be avoided by changing the client to make any subsequent requests as the temp account that was created for them in the first request, so it seems useful to let the client know which limit they're hitting.

Task breakdown notes:

Subtask 1: too many temp users

  • config hack to override $wgTempAccountCreationThrottle
  • e2e test setting the limit to 1, expect it to fail with the second request
  • temp user creation happens in MediaWikiEditEntity::attemptSave() via $this->createTempUserIfNeeded(); so we may also be able to handle it in UpdateExceptionHandler
  • add to OAS

Subtask 2: too many requests (rate limiting)

  • config hack to override $wgRateLimits
  • e2e test setting the limit to 1, expect it to fail with the second request
  • handling the error can happen in UpdateExceptionHandler
  • add to OAS
Dima_Koushha_WMDE renamed this task from [Create error] Too many requests to ⏳ [Create error] Too many requests .Sep 17 2024, 2:43 PM

Change #1074422 had a related patch set uploaded (by Jakob; author: Jakob):

[mediawiki/extensions/Wikibase@master] REST: Add 429 response to OAS for edit routes

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

Change #1074422 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Add 429 response to OAS for edit routes

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

I finally have time for this buuut how do I test this? Especially the rate limit reached one?