Skip to content

fix(dashboard-api): prefer gateway.auth.token over stale env token (DocPanel 401)#460

Merged
webdevtodayjason merged 1 commit into
devfrom
fix/docpanel-token-prefer-config
Jun 16, 2026
Merged

fix(dashboard-api): prefer gateway.auth.token over stale env token (DocPanel 401)#460
webdevtodayjason merged 1 commit into
devfrom
fix/docpanel-token-prefer-config

Conversation

@webdevtodayjason

Copy link
Copy Markdown
Contributor

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)

resolveDashboardApiToken resolved env DASHBOARD_API_TOKEN first. 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 accepts gateway.auth.token (resolved live per-request), but the gateway sent the stale plist token → every DocPanel save (workflow output node) returned HTTP 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.ts updated 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

…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>
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8ceb2a13-222f-43fb-8a58-51b71d0bba86

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/docpanel-token-prefer-config

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

@webdevtodayjason
webdevtodayjason merged commit 48314e5 into dev Jun 16, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant