fix(alibaba-token-plan): personal requests rejected with Workspace.NotAuthorised (hardcoded switchAgent) - #2533
Conversation
…tAuthorised The Personal/Solo path hardcoded `switchAgent: 1_233_135` in the `cornerstoneParam` request body. The gateway binds that value to a specific account's workspace, so for any other account the call is rejected with `BailianGateway.Workspace.NotAuthorised` even though the outer envelope claims `code: "200"`. Omitting the field lets the gateway resolve the session's default workspace. Also: - Resolve `sec_token` best-effort for personal requests (the browser always sends it; some accounts are rejected without it) and append it to the body when available, mirroring the Teams path. - `throwIfErrorPayload` now reads `errorCode`/`errorMsg` from the nested frame that carries `success: false`, so the real gateway error is surfaced instead of a misleading "API error: 200". Authorization-family errors map to `invalidCredentials` so the UI prompts for re-authentication. Fixes steipete#2500. Verified live against the mainland Personal/Solo API and covered by new regression tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Codex review: needs real behavior proof before merge. Reviewed August 3, 2026, 11:55 AM ET / 15:55 UTC. ClawSweeper reviewWhat this changesThe PR removes the hardcoded workspace selector from Alibaba Personal/Solo quota requests, sends a dashboard security token when available, surfaces nested gateway errors, and preserves valid sessions on permission failures. Merge readiness⛔ Blocked until real behavior proof is added - 2 items remain Current Priority: P2 Review scores
Verification
How this fits togetherCodexBar’s Alibaba Token Plan provider turns imported browser cookies into quota API requests and maps responses into usage or authentication state for the menu-bar app and CLI. Personal/Solo request composition and error classification determine whether a cached browser session can display quota data. flowchart LR
A[Imported browser cookies] --> B[Alibaba provider]
B --> C[Personal request builder]
C --> D[Alibaba quota gateway]
D --> E[Nested usage or error payload]
E --> F[Provider cache policy]
F --> G[Menu bar and CLI]
Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Merge the focused request and error-handling repair once a Personal/Solo account provides redacted after-fix output for the exact head, retaining deterministic tests for token presence, omitted workspace selection, nested errors, and cache preservation. Do we have a high-confidence way to reproduce the issue? Yes, by source: current main sends the literal workspace selector on the Personal request path, the field the report identifies as workspace-bound. A live Personal/Solo account is still required to prove the after-fix external gateway response. Is this the best way to solve the issue? Yes: removing the captured workspace selector is the narrowest correction to the source-proven request defect, and optional token/error handling stays within the existing provider request boundary. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against eddf0b4a1809. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
Problem
Alibaba Personal/Solo Token Plan requests could fail with
BailianGateway.Workspace.NotAuthorisedwhile CodexBar displayed the misleadingAPI error: 200. This affects the mainland China and Singapore personal-account paths discussed in #2500, #2349, and #2370.Root cause
The Personal request body forwarded a captured Teams
switchAgentvalue. Alibaba binds that value to a particular workspace, so personal sessions outside that workspace are rejected. Separately, the real gateway error lives in a nestedsuccess: falseframe inside an outer 200-OK envelope, which the fetcher did not inspect.Fix
switchAgentand let the gateway resolve the personal session's workspace.sec_tokenwith the existing best-effort dashboard/user-info/cookie flow and include it only when present.errorCodeanderrorMsgvalues so the provider shows the real gateway failure instead ofAPI error: 200.Workspace.NotAuthorisedas a provider permission error rather than invalid credentials, preserving valid cached browser sessions instead of evicting and re-importing them.Verification
swift test --filter AlibabaTokenPlan: 50 tests passed, including token presence/absence, captured-agent removal, nested-error extraction, authorization classification, and cache preservation.make check: clean SwiftFormat and SwiftLint.make test: all 758 selections passed in 64/64 groups on the first pass.No maintainer-side live CN or Singapore validation was possible because those account credentials are not available here. Reporter verification with a Personal/Solo account is requested after the fix ships in the next release.
Thanks @wait2050 for the original investigation and implementation.