Skip to content

fix(deeplink): preserve custom env fields when importing Claude providers#266

Open
thedavidweng wants to merge 3 commits into
SaladDay:mainfrom
thedavidweng:fix/261-deeplink-preserve-custom-env-fields
Open

fix(deeplink): preserve custom env fields when importing Claude providers#266
thedavidweng wants to merge 3 commits into
SaladDay:mainfrom
thedavidweng:fix/261-deeplink-preserve-custom-env-fields

Conversation

@thedavidweng

Copy link
Copy Markdown
Contributor

Summary

When importing Claude providers through deeplinks (ccswitch://v1/import?...), custom environment variables were silently dropped. build_claude_settings constructed env from scratch with only known keys (ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL, model keys), discarding any user-defined variables like ANTHROPIC_CUSTOM_HEADERS or proxy settings.

The CLI/TUI provider creation path already preserved these fields by cloning existing settings — this fix brings the deeplink import path to parity.

Changes

src-tauri/src/deeplink/mod.rs

  • Add custom_env: Option<Map<String, Value>> field to DeepLinkImportRequest

src-tauri/src/deeplink/provider.rs

  • In merge_claude_config: collect non-standard env keys into custom_env
  • In build_claude_settings: merge custom_env entries into the output env

Closes #261

@thedavidweng thedavidweng marked this pull request as ready for review June 10, 2026 03:15
…ders

When importing Claude providers through deeplinks, custom environment
variables (e.g. ANTHROPIC_CUSTOM_HEADERS, proxy settings) were silently
dropped because build_claude_settings constructed env from scratch with
only known keys.

- Add custom_env field to DeepLinkImportRequest to carry unknown env keys
- In merge_claude_config, collect non-standard env keys into custom_env
- In build_claude_settings, merge custom_env into the output env object

Closes SaladDay#261
The PR added custom_env to the struct definition and provider.rs usage
but missed updating the parser constructor, causing a compile error.
@thedavidweng thedavidweng force-pushed the fix/261-deeplink-preserve-custom-env-fields branch from 32e4152 to 7b5e59d Compare June 10, 2026 21:17
@SaladDay

Copy link
Copy Markdown
Owner

@thedavidweng Thanks for the fix, this is a useful parity improvement.

I found one small blocker before merge: current main supports both Claude auth env keys, ANTHROPIC_AUTH_TOKEN and ANTHROPIC_API_KEY, but the deeplink merge path only reads/excludes ANTHROPIC_AUTH_TOKEN. So an inline config that only has ANTHROPIC_API_KEY can still fail with “API key is required”, or can end up with both auth env keys if apiKey is provided in the URL.

Could you update merge_claude_config to also read ANTHROPIC_API_KEY, add it to the known key list, and add a small deeplink import test for that case? After that I think this should be good to merge.

- Read ANTHROPIC_API_KEY as fallback when ANTHROPIC_AUTH_TOKEN is absent
- Add ANTHROPIC_API_KEY to known_keys to prevent leaking into custom_env
- Add test for ANTHROPIC_API_KEY import path
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.

fix(deeplink): custom env fields lost when importing Claude providers

2 participants