fix: preserve user-defined env in settings.json - #76
Merged
Conversation
Previously, `delete(settingsWithHook, "env")` removed all user-defined env from settings.json on every ccc run (Issue #74). Now: - Only write user's non-conflicting env keys to settings.json (filtered by managed keys and ANTHROPIC_*/CLAUDE_* prefix) - Pass only base + provider env to subprocess (not user env) - Add FilterUserEnvForSettings and MergeEnvMaps helper functions - Remove unused CleanEnvInSettings function
This was referenced Mar 26, 2026
This was referenced May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
delete(settingsWithHook, "env")previously removed all user-defined env from settings.json on everycccrunFilterUserEnvForSettingsto only keep safe user env keys (excluding managed/base/provider keys andANTHROPIC_*/CLAUDE_*prefixed keys)MergeEnvMapsto merge multiple env maps for subprocess env constructionCleanEnvInSettingsfunction and its testsTest plan
TestFilterUserEnvForSettings— 8 subtests covering conflict exclusion, prefix exclusion, nil/empty inputTestMergeEnvMaps— 7 subtests covering basic merge, override, nil/empty handlingTestSwitchWithHookUserEnv/preserves user env without conflicts— verifies filtered user env in settings.json and base+provider-only subprocess envTestSwitchWithHookUserEnv/removes conflicting user env— verifies conflicting keys are filtered outTestSwitchWithHook/switch to existing provider— no regression./check.sh— all checks passed (lint, test with race detector, build)