Skip to content

fix(router): prioritize project-specific credentials over system defaults#1403

Open
jkwiecien-solvd wants to merge 3 commits into
mongrel-intelligence:devfrom
jkwiecien-solvd:fix/claude-oauth-token-override
Open

fix(router): prioritize project-specific credentials over system defaults#1403
jkwiecien-solvd wants to merge 3 commits into
mongrel-intelligence:devfrom
jkwiecien-solvd:fix/claude-oauth-token-override

Conversation

@jkwiecien-solvd

Copy link
Copy Markdown
Contributor

Description

This PR fixes an issue where project-specific credentials (specifically CLAUDE_CODE_OAUTH_TOKEN) configured in the UI/database were being overridden by the global system default/fallback token from the router's process environment (process.env.CLAUDE_CODE_OAUTH_TOKEN).

Cause

In src/router/worker-env.ts, appendOptionalEnvVars was appending process-level infrastructure environment variables to the end of the container's environment array. Because this was done after resolving project-specific credentials, the global fallback CLAUDE_CODE_OAUTH_TOKEN was placed later in the array. Since Docker overrides duplicates with the latter entry, the worker container ended up using the expired/rate-limited system token instead of the project-specific one configured in the UI.

Fix

  • Introduced a hasEnvVar helper to check if a variable prefix already exists in the environment array.
  • Updated appendOptionalEnvVars to only push process environment variables if they aren't already set by project-specific credentials.
  • Added a unit test in tests/unit/router/worker-env.test.ts to verify the prioritization and prevent future regressions.

jkwiecien-solvd and others added 3 commits June 14, 2026 10:55
Adds claude-opus-4-8 and claude-opus-4-8[1m] to the CLAUDE_CODE_MODELS
list, rate limits, and cost pricing tables alongside the existing 4.7
entries. Updates the backend unit tests to assert the new model IDs and
the expanded model count.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Merge feat/claude-opus-4-8 into dev-jacek.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/router/worker-env.ts 80.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

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