log: clarify credential-rotation messages — HTTP %s instead of "Credential %s" (Copilot #15414)

Copilot's review on #15414 flagged that the rotation log lines read
``"Credential %s (billing) — rotated to pool entry %s"`` where the
first ``%s`` is bound to ``rotate_status`` (an HTTP status code, e.g.
429), not a credential ID.  Reading the literal log line —
``"Credential 429 (billing) — rotated to pool entry cred-2"`` — would
suggest "credential 429" was rotated, which is meaningless and
actively confusing during incident debugging.

Same issue existed on the three sibling branches (billing,
rate_limit, auth refresh-failed) plus the new overloaded branch this
PR adds.  Drive-by fix all four with the same ``HTTP %s (reason) —
rotated credential to pool entry %s`` shape so:

  HTTP 429 (provider overloaded) — rotated credential to pool entry cred-2

reads correctly as "we got HTTP 429, classified it as provider
overloaded, rotated to credential cred-2".

No behaviour change.  145/145 tests still pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Brian D. Evans 2026-04-24 17:47:31 -07:00
parent 24461ec0bc
commit b0d5d63d9d

View file

@ -5565,7 +5565,7 @@ class AIAgent:
next_entry = pool.mark_exhausted_and_rotate(status_code=rotate_status, error_context=error_context) next_entry = pool.mark_exhausted_and_rotate(status_code=rotate_status, error_context=error_context)
if next_entry is not None: if next_entry is not None:
logger.info( logger.info(
"Credential %s (billing) — rotated to pool entry %s", "HTTP %s (billing) — rotated credential to pool entry %s",
rotate_status, rotate_status,
getattr(next_entry, "id", "?"), getattr(next_entry, "id", "?"),
) )
@ -5580,7 +5580,7 @@ class AIAgent:
next_entry = pool.mark_exhausted_and_rotate(status_code=rotate_status, error_context=error_context) next_entry = pool.mark_exhausted_and_rotate(status_code=rotate_status, error_context=error_context)
if next_entry is not None: if next_entry is not None:
logger.info( logger.info(
"Credential %s (rate limit) — rotated to pool entry %s", "HTTP %s (rate limit) — rotated credential to pool entry %s",
rotate_status, rotate_status,
getattr(next_entry, "id", "?"), getattr(next_entry, "id", "?"),
) )
@ -5598,7 +5598,7 @@ class AIAgent:
next_entry = pool.mark_exhausted_and_rotate(status_code=rotate_status, error_context=error_context) next_entry = pool.mark_exhausted_and_rotate(status_code=rotate_status, error_context=error_context)
if next_entry is not None: if next_entry is not None:
logger.info( logger.info(
"Credential %s (provider overloaded) — rotated to pool entry %s", "HTTP %s (provider overloaded) — rotated credential to pool entry %s",
rotate_status, rotate_status,
getattr(next_entry, "id", "?"), getattr(next_entry, "id", "?"),
) )
@ -5618,7 +5618,7 @@ class AIAgent:
next_entry = pool.mark_exhausted_and_rotate(status_code=rotate_status, error_context=error_context) next_entry = pool.mark_exhausted_and_rotate(status_code=rotate_status, error_context=error_context)
if next_entry is not None: if next_entry is not None:
logger.info( logger.info(
"Credential %s (auth refresh failed) — rotated to pool entry %s", "HTTP %s (auth refresh failed) — rotated credential to pool entry %s",
rotate_status, rotate_status,
getattr(next_entry, "id", "?"), getattr(next_entry, "id", "?"),
) )