Skip to content

Report a pooled account with a rejected login as expired in Provider usage - #7420

Closed
seklow wants to merge 1 commit into
get-bb:mainfrom
seklow:account-pool-expired-login-usage
Closed

seklow wants to merge 1 commit into
get-bb:mainfrom
seklow:account-pool-expired-login-usage

Conversation

@seklow

@seklow seklow commented Nov 11, 2026 •

Copy link
Copy Markdown

Human comments

What was wrong

Account Pooler's usage source reported every account error as the generic error usage state, including an OAuth login that the token endpoint had rejected (invalid_grant). Provider usage treats error as a failed refresh: the account's row keeps its last measurement, unmarked, and the whole group gets "Couldn't refresh. Showing last update.", so nothing says which account needs a new sign-in. The usage contract already has an expired state that Provider usage shows on the account's own row with a sign-in hint, but the pool kept only the free-text quota.error and had no typed record of why an account is in error. Root cause and reproduction: #7417 and its report.

What changed

Only plugins/account-pool.

  • src/hub.ts: an account error that comes from a rejected OAuth refresh (OAuthRefreshError) is stored with loginRejected. A stored error is re-thrown as a login rejection while the account's current refresh token is on record as rejected, so the existing catches keep the classification. This also marks errors stored before this change on the first usage refresh after the upgrade, without sending the rejected token again.
  • src/store.ts, src/contracts.ts, src/quota.ts: AccountQuota.loginRejected, persisted in a new login_rejected_error column that holds the text of the error it classifies. The flag reads true only while that same error is stored, so an older build that clears or replaces the error (rollback) cannot leave a stale classification behind.
  • src/usage-source.ts: accounts with loginRejected report the expired usage state.
  • bb pool status --json and bb pool account list --json gain loginRejected; the skill reference says so. No daemon wire change.

Not changed, and known limits:

How you verified

pnpm exec turbo run typecheck test lint --filter=bb-plugin-account-pool: 399 tests pass, typecheck and lint are clean.

Tests added or extended, for Claude and Codex accounts; each fails without the change:

  • src/refresh-rejection.test.ts: the flag stays false while a rejected refresh token's access token still works, is set once the account enters error (background expiry and upstream 401), and is cleared by signing in again. An error stored without the flag is marked on the next refresh without another token request. A rejection recorded for a different refresh token leaves the error unmarked.
  • src/server.test.ts: the usage source returns expired after the rejection and after a failed manual refresh, and its normal state after a successful one.
  • src/store.test.ts: when a build without the column clears the error, or replaces it with another, the flag reads false.

I also removed each key line in turn (the stored-error comparison, the typed re-throw, the flag in failAccount, the expired branch) and confirmed the tests above fail.

Not checked in a running app: the row hint for an expired pooled account is existing Provider usage behaviour, covered by plugins/provider-usage/app.test.tsx.

Fixes #7417

🤖 Generated with Claude Code

AGENT GENERATED

…usage

Account Pooler reported every account error to Provider usage as the
generic error state, so an OAuth login that the token endpoint had
rejected kept its last usage on screen behind a group-wide refresh
notice. The pool now stores whether an account's error is a rejected
login and reports such accounts as expired, which Provider usage shows
on the account's own row with a sign-in hint.

Fixes get-bb#7417

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@github-actions github-actions Bot added the needs-approval PR author is not on the approved contributor list label Nov 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the pull request, @seklow. It was closed automatically because it does not meet the requirements below yet. This is an automated check, not a review of the change.

Contributor approval. bb reviews pull requests only from approved contributors, and you are not on the list yet. Join the #contributors channel in Discord (https://discord.gg/kvBU6tJhcJ), post a link to your pull request, and explain what it changes and why. A maintainer then adds you to the list and reopens the pull request.

See CONTRIBUTING.md for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-approval PR author is not on the approved contributor list

Projects

None yet

1 participant