You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(claude): stop a project dotenv from overriding claude.ai subscription auth
Closes#701.
The bundled Bun runtime auto-loads a project `.env`/`.env.local` before any
opencodex code evaluates, so an `ANTHROPIC_API_KEY` sitting in whatever
directory the user launched from was indistinguishable from a deliberate shell
export by the time buildClaudeEnv read process.env. Claude Code disables
claude.ai connectors the moment either token slot is populated, so a healthy
subscription silently fell through to API billing and reported a credit-balance
error.
The npm launcher runs under Node, which does NOT auto-load dotenv, so it is the
last point that still knows the difference. It now records which Anthropic slots
were already non-empty in `OCX_PRE_BUN_ANTHROPIC_ENV` and passes that to the Bun
child; buildClaudeEnv drops any slot populated now but absent then, and deletes
the marker before it reaches Claude Code. A genuine shell export still wins, in
every auth mode, so auto-mode API-key auth keeps working.
Two details the audit forced:
- The discriminator is provenance, not `authMode === "subscription"`. Auto is
stored as an ABSENT key and is the GUI default, and auto+present resolves to
subscription, so keying off the literal would have missed most affected users.
- Auth detection is rebound to the sanitized env. Leaving it on the raw base let
a credential the child never receives decide the marker, which left an
auto-mode user with no credential AND no PROXY_MARKER.
A global `--no-env-file` was rejected: config interpolation and provider
settings legitimately read the project environment.
The transport test spawns real processes because the empty-string marker ("the
launcher ran and saw no slots") must stay distinct from an absent one ("no
launcher, change nothing"); the unit tests inject that marker directly and would
stay green if a platform ever collapsed the two.
0 commit comments