Skip to content

[Bug]: Claude: prepaid/credits returns 403 on Team plans and is retried on every refresh, triggering HTTP 429 on the usage endpoint #123

Closed

Description

@guidi-injenia

Plugin version

2.4.0

Area

Bar widget

Environment

AiOverviewControl 2.4.0, Dux/DMS 2.0, quickshell 0.3.2, Hyprland 0.57, openSUSE Tumbleweed.
Claude Team plan (non-admin member), 2 monitors (2 widget instances), refreshInterval = 15 min.

Steps to reproduce

Problem
On a Team plan GET /api/oauth/organizations//prepaid/credits answers 403 (the member can't read org credits). get-claude-usage only writes claude-prepaid-cache.json on a 200, so the call is repeated on every run of the script: each widget instance, each manual refresh, even when the usage request itself is served from the 120 s cache.

The account then gets rate limited on /api/oauth/usage (429, ~1 h Retry-After) almost immediately.

Expected behavior

No 429 from claude usage statistics

Actual behavior

Evidence (I added a one-line log after each curl in get-claude-usage):

With prepaid enabled:
16:25:52 usage 200 (manual refresh)
16:25:53 prepaid 403
16:27:36 prepaid 403 (instance 1, usage served from cache)
16:27:37 prepaid 403 (instance 2, usage served from cache)
16:42:36 usage 429 → backoff 1 h

With the prepaid request skipped locally (nothing else changed):
17:42:37 usage 200
17:57:37 usage 200
18:12:37 usage 200
18:27:37 usage 200
No more 429s. Another plugin polling only /api/oauth/usage every 5 min never hit a 429 on the same account for days.

Suggested fix

  • Cache a 403/404 from prepaid/credits as "not available" (e.g. for 24 h) instead of retrying on every run, or skip the call when it has already been refused.
  • Optionally a setting to disable the prepaid/credits lookup.
  • Consider honouring the usage backoff/cache for the prepaid call as well (it is only skipped while a usage backoff is active).

Related: #96

Local checks

Activity

  1. added
    bug
    on Nov 11, 2026
  2. bernardopg commented on Nov 11, 2026

    @bernardopg
    Owner

    Thank you @guidi-injenia, both for the report and for logging every request: the prepaid 403 lines next to the cached usage request, one per monitor, pinned it down straight away. You had already found the root cause.

    What happened. Usage credits come from GET /api/oauth/organizations/<org>/prepaid/credits, which shares the account's rate limit with /api/oauth/usage. A Team member who is not an admin gets 403 there, and the adapter only recorded a successful answer. So every run asked again: each widget instance, each manual refresh, even while the usage request was served from its 120 s cache. With two monitors that adds up quickly, and the usage endpoint answered 429 with the one hour Retry-After you saw. I reproduced it with a fake endpoint answering 403: four runs made four credits requests and one usage request.

    The fix (#124, with a follow-up in #125) covers your suggestions:

    • Cache the refusal: a 403 or 404 is remembered for 24 hours per organization, and the card shows no credits. After the fix, the same four runs made one credits request.
    • Honour the usage backoff for credits too: a 429 on the credits endpoint starts the same backoff as the usage endpoint (Retry-After honoured), and credits are never asked while it holds, also when the usage numbers come from the cache. The card's Updated line then shows Rate limited · next try HH:MM.
    • Other failures (5xx, network) retry after the usual 10 minutes and keep the last good balance. Switching organization re-checks at once.

    I did not add a setting to turn the credits lookup off. With the refusal cached, a Team account now sends one credits request a day, which shouldn't count against the limit. If you still see 429s on 2.4.1, I'm happy to add one.

    It's out in v2.4.1. Update through Settings → Plugins → Check for updates; no restart is needed. The first refresh asks for credits once more, since the record 2.4.0 wrote doesn't say which organization it belongs to; after that it stays quiet for a day. To check, jq . ~/.cache/AiOverviewControl/claude-profiles/*/claude-prepaid-cache.json should show "status": "403" with the time it was checked, and your one-line curl log should show at most one prepaid line a day.

    If 429s come back on 2.4.1, please reopen this with that log. Your report is credited in the changelog. Thanks again!

  3. added a commit that references this issue on Nov 12, 2026
    a610e26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions