Problem/Motivation

When the Overpass server answers 502 Bad Gateway or 503 Service Unavailable, OverpassApi throws on the first attempt. Only 408, 429, 500 and 504 are retried; every other status falls to the default branch of the switch ($code) in the request loop in src/OverpassApi.php.

The public server at overpass-api.de answers 502 when it is busy. The response body says the server is at capacity and asks the client to retry with exponential backoff. On 17 November 2026, 7 of 17 requests in one run got this answer, and each succeeded when sent again a few seconds later.

Two smaller things in the same code:

  • The default branch logs every failure it throws as "Bad Request", including 5xx answers.
  • The wait between attempts is always lock_time seconds. The server asks for a wait that grows.

Steps to reproduce

  1. Point overpass_api.settings:endpoint at a server that answers 502, or mock the HTTP client to return a 502 followed by a 200.
  2. Call OverpassApiInterface::execute() with any query.
  3. An OverpassApiHttpException with code 502 is thrown at once, whatever repeat_attempts is set to.

Proposed resolution

  • Retry 502 and 503 as 504 is retried.
  • Log "Bad Request" for 400 only, and log other statuses as what they are.
  • Make the wait grow with each attempt, within the existing timeout and attempt settings.

Remaining tasks

  • Merge request with tests: a 502 then a 200 succeeds, a 503 then a 200 succeeds, and a 502 on every attempt throws after repeat_attempts.

API changes

None. Callers that catch the exception see it later, after the retries, instead of at once.

This comment was drafted by an LLM before it was reviewed by me.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

tbcs created an issue.