Repository navigation
fix(config): skip a rejected env override in every command, not just wt list - #4358
Conversation
The help added in #4348 says invalid environment overrides are ignored with a warning while the valid ones apply. That holds for `wt list` and other tolerant loads, but `wt switch`, `wt merge`, `wt remove`, and the `wt step` commands load config strictly and exit 1 on the same override, as `test_eval_invalid_env_override_keeps_one_fatal_diagnosis` pins. Also refresh the `LoadError::Env` docstring: since #4348 it is pushed once per rejected setting, and `vars` lists only that setting's vars.
|
why would we have different intended behavior?! |
worktrunk-bot
left a comment
There was a problem hiding this comment.
@max-sixty, it shouldn't differ. The original sentence describes the intended design, and the strict commands contradict it. This PR's docs rewording documented a bug as behavior, so I'm replacing it with a loader fix.
Startup prewarm already loads the user config tolerantly and prints ▲ Ignoring env var overrides: …. The strict commands then reload through UserConfig::load(), and load_with_cause turns the same rejection into ✗ Failed to load config. So they say the override is ignored and then exit 1 because of it. The wt step eval test I cited as evidence of intent pins that contradictory output. It doesn't show a design choice.
The follow-up push makes load_with_cause skip LoadError::Env, keeps file, --config-set, and validation failures fatal, and restores the original doc sentence. The eval test now asserts that the command succeeds and prints the warning once.
One consequence needs your call before merge. A mistyped override such as WORKTRUNK__MERGE__REMOVE=flase or WORKTRUNK__REMOVE__DELETE_BRANCH=nope used to stop wt merge or wt remove. Now the command warns and falls back to the file or default value, which can mean removing the worktree or deleting an integrated branch. That matches the documented contract and wt list, but it loosens what gates a removal, so I'm leaving it to you.
Commands that load config through UserConfig::load() (wt switch, merge, remove, for-each, the wt step commands) treated a rejected WORKTRUNK_* override as fatal, after the startup prewarm had already warned that it was being ignored. load_with_cause now skips LoadError::Env, so every command falls back to the file layers for that setting and still applies the other overrides, as documented and as wt list already does. File, --config-set, and validation failures stay fatal. Reverts this branch's docs rewording, which described the strict path as intended.
|
@worktrunk-bot a rejected env override should warn and fall back in every command, as here. Please rewrite the body, since #4412 deleted the doc sentence it quotes; then this can merge.
|
A rejected
WORKTRUNK_*env override now warns and falls back in every command, the same way it already did inwt listand other tolerant loads. Before this change, commands that load config throughUserConfig::load()treated it as fatal. These arewt switch,wt merge,wt remove,wt for-each, and thewt stepcommands. Each printed▲ Ignoring env var overrides: …during the startup prewarm, then exited 1 with✗ Failed to load configfor the same variable. The two paths shouldn't disagree, so the tolerant behavior now applies to all of them.load_with_causenow skipsLoadError::Env. The rejected setting falls back to the file layers or its default, and other valid overrides still apply. User-file parse errors,--config-setfailures, and validation failures stay fatal for these commands.In practice, a mistyped override such as
WORKTRUNK__MERGE__REMOVE=flaseorWORKTRUNK__REMOVE__DELETE_BRANCH=nopeno longer stopswt mergeorwt remove. The command warns once and uses the file or default value instead.Verification: with
WORKTRUNK__LIST__BRANCHES=not-a-bool,wt step eval '{{ branch }}'prints the single startup warning and outputsmain(exit 0).test_eval_skips_invalid_env_overridepins this and replaces the test that pinned the old exit 1. TheLoadErrordocstrings are updated to match: since #4348,LoadError::Envis emitted once per rejected setting, and strict loading no longer treats it as fatal. The public docs no longer describe this case (#4412 removed that sentence), so no doc change is needed.