Skip to content

fix(usage): recover missing Codex hub plans from auth metadata - #10878

Open
kalvenschraut wants to merge 1 commit into
pingdotgg:mainfrom
RTVision:fix/codex-hub-plan-fallback
Open

fix(usage): recover missing Codex hub plans from auth metadata#10878
kalvenschraut wants to merge 1 commit into
pingdotgg:mainfrom
RTVision:fix/codex-hub-plan-fallback

Conversation

@kalvenschraut

@kalvenschraut kalvenschraut commented Sep 9, 2026

Copy link
Copy Markdown

What changed

When CLIProxyAPI's usage response omits plan_type, T3 can lose the account's plan label and classify a Free or Go quota window as a session window even though the auth-file metadata contains the plan.

Resolve the plan once from the usage response, then id_token.plan_type, then the legacy id_token.chatgpt_plan_type. Use that value for both the label and quota conversion. The current CLIProxyAPI management handler emits plan_type.

UI

Synthetic browser fixture generated from the baseline and patched adapters. The usage response omits the plan and window duration; auth metadata contains plan_type: "free". The quota is now classified as Monthly.

Before After
Before After

Verification

  • 32 adapter/converter tests passed. Regression coverage checks Free and Go with both current and legacy token fields, asserting the plan labels and monthly window duration when the usage plan is absent.
  • Server package typecheck and changed-file lint passed.
  • The adapter produces the shared report for all clients. Browser evidence uses synthetic fixtures; no live hub or mobile end-to-end test was run.
  • Fable approved the final diff after checking the management-handler schema evidence.

Implemented with GPT-6 in Codex; reviewed with claude-fable-5-1 through Claude Code.

Summary by CodeRabbit

  • Bug Fixes
    • Improved Codex account plan detection when upstream usage data omits subscription metadata.
    • Subscription labels now correctly identify Free and Go plans using available current or legacy account information.
    • Rate-limit snapshots and monthly quota windows now reflect the resolved account plan more reliably.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Sep 9, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 836db7a

Macroscope's review found this PR approvable — This is a narrow, well-tested usage-adapter fix that preserves existing behavior when upstream plan metadata is present and recovers only missing Free/Go plan information from existing auth metadata. Its production impact is limited to accurate subscription labels and quota-window presentation.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 02be3389-14e4-47be-a60a-f75749ae584d

📥 Commits

Reviewing files that changed from the base of the PR and between 08463e2 and 836db7a.

📒 Files selected for processing (2)
  • apps/server/src/usage/cliproxyApi.test.ts
  • apps/server/src/usage/cliproxyApi.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

Codex plan resolution now falls back to token metadata when upstream usage responses omit plan information. Tests cover current and legacy plan fields for Free and Go accounts.

Changes

Codex plan resolution

Layer / File(s) Summary
Token metadata and plan mapping
apps/server/src/usage/cliproxyApi.ts, apps/server/src/usage/cliproxyApi.test.ts
The auth schema accepts id_token.plan_type. Plan resolution falls back to current and legacy token fields. Tests verify subscription labels and monthly quota windows for Free and Go accounts.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 836db

Codex usage now recovers missing plan metadata from current and legacy token fields, preserving correct account labels and monthly quota windows for Free and Go plans. No current merge-blocking risk remains.

Suggested reviewers: juliusmarminge

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: recovering missing Codex plan data from authentication metadata.
Description check ✅ Passed The description explains what changed, why it changed, UI evidence, verification results, and testing limitations. It does not use the exact template headings for “Why,” “UI Changes,” and “Checklist,”…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

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

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant