Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

The 401 Retry Bug: Auditing an Agent-Written Backoff Loop With a Fake Server

Description and use

Problem: An agent‑generated exponential backoff loop incorrectly retries on all Exceptions, ignores status codes, and silently returns None, potentially corrupting downstream logic. Solution: Identify defects in the diff, run a lightweight fake server to record timestamps, and write unit tests to assert correct timing and behavior.

Problem

A pull request added an exponential backoff loop that retries a 401 response six times, sleeping about 63 seconds, but the retry logic contains multiple defects: it catches all Exceptions, retries on non‑auth errors, ignores Retry‑After headers, and silently returns None.

Outcome

The review uncovered that the agent‑written backoff loop incorrectly retries on all Exceptions, ignores status filtering, and silently returns None, potentially corrupting downstream callers. A minimal fake server and unit tests were used to validate timing and expose the defects.

Workflow

  • Read the diff and identify retry smells
  • Stand up a fake server that records timestamps
  • Write unit tests that assert timing and behavior

Evidence

It also retries a 401 six times. Along the way it sleeps about 63 seconds.

Source

The first smell is except Exception. It catches KeyError from a bug in the caller. It catches programming errors and network errors with the same hand.

Source

The second smell is the missing status filter. A 400 and a 503 produce identical behavior. Authentication failures get retried, which is pure latency with no upside.

Source

The third smell is return None. A silent None corrupts every downstream caller.

Source

  • Record date: 2026-10-26T12:26:16.712Z