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

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

Описание и применение

Проблема: агент‑генерируемый PR добавил цикл экспоненциального отката, который повторяет запросы с кодом 401, игнорирует заголовок Retry-After и возвращает None, что приводит к ошибкам downstream. Решение: создать фиктивный сервер, записывающий временные метки, и написать тесты, проверяющие количество и интервалы запросов.

Задача

An agent-generated pull request added an exponential backoff loop that incorrectly retries 401 responses, ignores Retry-After headers, and silently returns None, causing downstream failures.

Результат

The review uncovered that the backoff loop retries on authentication failures, ignores Retry-After, and silently returns None, which corrupts downstream callers. The fake server and tests demonstrated the problematic timing and request pattern.

Рабочий процесс

  • Read the diff and identify retry smells
  • Build a fake HTTP server that records timestamps
  • Write unit tests that assert request timing and count

Доказательства

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

Источник

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.

Источник

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.

Источник

  • Дата записи: 2026-10-26T12:26:19.574Z