fix(dashboard-api): prefer gateway.auth.token over stale env token (DocPanel 401)#460
Merged
Merged
Conversation
…D_API_TOKEN DocPanel saves (workflow output nodes) were 401ing because resolveDashboardApiToken sent the env DASHBOARD_API_TOKEN first, and that env value — sourced from the gateway LaunchAgent plist / service-env — had drifted stale (a 48-char token) versus what the api-server accepts. The api-server's accepted set always includes gateway.auth.token (resolved live per-request), but the gateway was sending the stale plist token instead, so every doc_panel save returned HTTP 401 Invalid token and failed the run's output node. Flip precedence: resolve gateway.auth.token (the value both gateway and api-server always agree on) first, fall back to the env var only when argent.json carries no gateway token. Still per-request (INV-1/INV-4), no module-load caching. Verified live root cause: curl with gateway.auth.token -> 200; with the plist env token -> 401. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Real fix for Bug #3 (the config reconcile in the earlier work did NOT hold — the stale token lives in the gateway LaunchAgent plist, regenerated on deploy, not in ~/.argentos/.env).
Root cause (verified live)
resolveDashboardApiTokenresolved envDASHBOARD_API_TOKENfirst. That env value is sourced from the gateway plist/service-env and had drifted stale (48-char token) vs. the api-server's accepted set. The api-server always acceptsgateway.auth.token(resolved live per-request), but the gateway sent the stale plist token → every DocPanel save (workflowoutputnode) returnedHTTP 401 Invalid token. Direct curl proved it:gateway.auth.token→ 200, plist env token → 401. A fresh run (87f13e5f) still 401'd after the env reconcile, confirming the env var wasn't the controllable source.Fix
Prefer
gateway.auth.token(the one value both gateway and api-server always agree on, read live) over the env var; fall back to env only when argent.json has no gateway token. Still per-request (INV-1/INV-4 green). Only affects gateway→api-server server-side calls (doc_panel, workflow output); the dashboard browser authenticates separately.Tests
src/utils/dashboard-api.test.tsupdated for the new precedence (10 cases incl. config-wins, env-fallback, trim, null, no-cache). tsgo 189 (unchanged); oxfmt clean; INV checks pass.🤖 Generated with Claude Code