fix: --config flag now fully overrides ~/.strix/cli-config.json#457
Merged
bearsyankees merged 3 commits intoApr 22, 2026
Merged
Conversation
…usestrix#377) Previously, env vars applied from the default config at module import time were not cleared when --config was later processed, causing settings from ~/.strix/cli-config.json to leak into runs that specified a custom config. Track which vars were applied by the initial default-config load in Config._applied_from_default. In apply_config_override, clear those vars before applying the custom config so only the custom file's settings take effect.
Contributor
Greptile SummaryThis PR fixes env-var leakage when Confidence Score: 5/5Safe to merge; the fix is correct for the described scenario and the test covers the regression path. The one comment is a speculative edge case (consecutive No files require special attention. Important Files Changed
Prompt To Fix All With AIThis is a comment left during a code review.
Path: strix/interface/main.py
Line: 531-539
Comment:
**Consecutive `--config` calls leak vars from the first custom config**
After `apply_config_override` runs once, `_applied_from_default` is reset to `{}`. If it is called a second time (e.g. an integration path that re-invokes argument processing), vars that were applied with `force=True` from the *first* custom config are not tracked anywhere, so they won't be cleared before the second custom config is applied — reproducing the same leakage the fix intends to prevent, just one level up.
A minimal guard would be to also track what `apply_saved_config(force=True)` applied and store it back into `_applied_from_default`, or at least clear all previously-tracked vars from `os.environ` including any set by a prior custom-config load. If `--config` can only ever be passed once per process lifetime this is a non-issue, but the function has no guard against being called twice.
How can I resolve this? If you propose a fix, please make it concise.Reviews (3): Last reviewed commit: "Make config override test setup explicit" | Re-trigger Greptile |
Collaborator
Collaborator
Collaborator
|
LGTM! Thanks @octo-patch |
hkboujrida
pushed a commit
to hkboujrida/strix
that referenced
this pull request
Apr 27, 2026
…trix#457) * fix: --config flag now fully overrides ~/.strix/cli-config.json (fixes usestrix#377) Previously, env vars applied from the default config at module import time were not cleared when --config was later processed, causing settings from ~/.strix/cli-config.json to leak into runs that specified a custom config. Track which vars were applied by the initial default-config load in Config._applied_from_default. In apply_config_override, clear those vars before applying the custom config so only the custom file's settings take effect. * Add config override regression test * Make config override test setup explicit --------- Co-authored-by: octo-patch <octo-patch@github.com> Co-authored-by: bearsyankees <bearsyankees@gmail.com>
Josz009
pushed a commit
to Josz009/strix
that referenced
this pull request
May 19, 2026
…trix#457) * fix: --config flag now fully overrides ~/.strix/cli-config.json (fixes usestrix#377) Previously, env vars applied from the default config at module import time were not cleared when --config was later processed, causing settings from ~/.strix/cli-config.json to leak into runs that specified a custom config. Track which vars were applied by the initial default-config load in Config._applied_from_default. In apply_config_override, clear those vars before applying the custom config so only the custom file's settings take effect. * Add config override regression test * Make config override test setup explicit --------- Co-authored-by: octo-patch <octo-patch@github.com> Co-authored-by: bearsyankees <bearsyankees@gmail.com>
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.
Fixes #377
Problem
When
--config custom.jsonis provided, Strix still applies settings from~/.strix/cli-config.jsonfor any keys that are absent from the custom config file.Root cause:
apply_saved_config()is called at module import time (before args are parsed), loading~/.strix/cli-config.jsonand setting those env vars inos.environ. Later,apply_config_override()loads the custom config and re-applies it withforce=True, overwriting keys that exist in the custom file — but vars that were set from the default file and are missing from the custom file remain inos.environunchanged.Solution
Track which env vars were actually set by the initial default-config load in
Config._applied_from_default. Inapply_config_override, clear those vars fromos.environbefore applying the custom config. This ensures:~/.strix/cli-config.jsonare cleared (no leakage).export STRIX_LLM=...) are never cleared — they were not set byapply_saved_config, so they are not in_applied_from_default.Changes
strix/config/config.py: addConfig._applied_from_defaultclass var; populate it inapply_savedwhen loading the default config.strix/interface/main.py: clear_applied_from_defaultentries inapply_config_overridebefore applying the custom config.Testing
Manually verified with two config files:
Before fix: running
strix --config custom.jsonstill inheritedLLM_API_BASEfrom the default file.After fix:
LLM_API_BASEis not set, onlySTRIX_LLM=custom-modelis applied from the custom file.