Skip to content

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

Open
worktrunk-bot wants to merge 2 commits into
mainfrom
nightly/clean-37104121248
Open

worktrunk-bot wants to merge 2 commits into
mainfrom
nightly/clean-37104121248

Conversation

@worktrunk-bot

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

Copy link
Copy Markdown
Collaborator

wt config --help says "Invalid environment overrides are ignored with a warning; other valid overrides still apply." Only tolerant loads such as wt list behaved that way. wt switch, wt merge, wt remove, wt for-each, and the wt step commands reload config through UserConfig::load(), and load_with_cause treated a rejected override as fatal. These commands printed ▲ Ignoring env var overrides: … during the startup prewarm and then exited 1 with ✗ Failed to load config for the same variable.

load_with_cause now skips LoadError::Env. Every command falls back to the file layers for the rejected setting and keeps the other overrides, as the docs say. User-file parse errors, --config-set failures, and validation failures stay fatal for these commands.

With WORKTRUNK__LIST__BRANCHES=nope, wt step eval '{{ branch }}' now prints the one warning and outputs main (exit 0). test_eval_skips_invalid_env_override replaces the test that pinned the old exit 1.

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 and uses the file or default value instead.

The LoadError docstrings are updated too. Since #4348, LoadError::Env is emitted once per rejected setting, and strict loading no longer treats it as fatal.

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

This branch has not been deployed

No deployments
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