Skip to content

fix: remove empty auth env placeholders from anthropic-thirdparty and openrouter presets#243

Open
eriksun421 wants to merge 1 commit intoop7418:mainfrom
eriksun421:fix/provider-empty-auth-env-vars
Open

fix: remove empty auth env placeholders from anthropic-thirdparty and openrouter presets#243
eriksun421 wants to merge 1 commit intoop7418:mainfrom
eriksun421:fix/provider-empty-auth-env-vars

Conversation

@eriksun421
Copy link

Fixes #241

Root Cause

anthropic-thirdparty and openrouter presets were storing empty auth key placeholders ({"ANTHROPIC_API_KEY":""} or {"ANTHROPIC_AUTH_TOKEN":""}) in extra_env. This caused two problems:

  1. inferAuthStyleFromLegacy() in provider-catalog.ts detects auth style by checking if ANTHROPIC_AUTH_TOKEN key exists in extra_env (regardless of value), so an empty placeholder could cause the wrong auth style to be inferred.
  2. The empty entries were persisted to DB and shown in the UI after save/reopen, confusing users into thinking their credentials were being cleared.

Fix

  • Remove the empty auth key placeholders from the preset definitions in ProviderManager.tsx and ProviderForm.tsx
  • On save for anthropic-thirdparty, strip any ANTHROPIC_API_KEY / ANTHROPIC_AUTH_TOKEN keys from extra_env instead of injecting empty ones — auth injection is already handled correctly via the api_key field in toClaudeCodeEnv()

Testing

  1. Add an Anthropic Third-party API provider with a valid base URL and API key
  2. Save and reopen — no empty auth env vars should appear in the UI
  3. Send a message — Claude Code subprocess should start successfully

… openrouter presets

Storing ANTHROPIC_API_KEY:"" or ANTHROPIC_AUTH_TOKEN:"" in extra_env caused
inferAuthStyleFromLegacy() to detect the wrong auth style, and left confusing
empty entries visible in the UI after save/reopen.

Auth injection is already handled via the api_key field in toClaudeCodeEnv(),
so these placeholders serve no purpose and should not be persisted.

Fixes op7418#241
@vercel
Copy link

vercel bot commented Mar 11, 2026

@w2sun is attempting to deploy a commit to the op7418's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

Anthropic Third-party API 服务商配置会注入空认证环境变量,导致 Claude Code 子进程退出 code 1

2 participants