Skip to content

fix(config): skip a rejected env override in every command, not just wt list - #4358

Merged
max-sixty merged 2 commits into
mainfrom
nightly/clean-37104121248
Nov 5, 2026
Merged

max-sixty merged 2 commits into
mainfrom
nightly/clean-37104121248

Conversation

@worktrunk-bot

@worktrunk-bot worktrunk-bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

A rejected WORKTRUNK_* env override now warns and falls back in every command, the same way it already did in wt list and other tolerant loads. Before this change, commands that load config through UserConfig::load() treated it as fatal. These are wt switch, wt merge, wt remove, wt for-each, and the wt step commands. Each printed ▲ Ignoring env var overrides: … during the startup prewarm, then exited 1 with ✗ Failed to load config for the same variable. The two paths shouldn't disagree, so the tolerant behavior now applies to all of them.

load_with_cause now skips LoadError::Env. The rejected setting falls back to the file layers or its default, and other valid overrides still apply. User-file parse errors, --config-set failures, and validation failures stay fatal for these commands.

In practice, a mistyped override such as WORKTRUNK__MERGE__REMOVE=flase or WORKTRUNK__REMOVE__DELETE_BRANCH=nope no longer stops wt merge or wt 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 outputs main (exit 0). test_eval_skips_invalid_env_override pins this and replaces the test that pinned the old exit 1. The LoadError docstrings are updated to match: since #4348, LoadError::Env is 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.

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.
@worktrunk-bot worktrunk-bot added the nightly-cleanup Issues found by nightly code quality sweep label Oct 3, 2026
@max-sixty

Copy link
Copy Markdown
Owner

why would we have different intended behavior?!

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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 worktrunk-bot changed the title docs(config): say which commands stop on an invalid env override fix(config): skip a rejected env override in every command, not just wt list Oct 3, 2026
@max-sixty

Copy link
Copy Markdown
Owner

@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.

This was written by Claude Code on behalf of max-sixty

@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

Rewrote the description. It now covers the behavior itself and no longer quotes the help sentence that #4412 removed. CI is green at 7d1399d, including codecov/patch. Merging is up to you.

@max-sixty
max-sixty merged commit b024ea8 into main Nov 5, 2026
37 checks passed
@max-sixty
max-sixty deleted the nightly/clean-37104121248 branch November 5, 2026 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nightly-cleanup Issues found by nightly code quality sweep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants