Skip to content

Retain valid environment overrides when another setting is invalid - #4348

Merged
max-sixty merged 3 commits into
mainfrom
codex/environment-overlay-validation
Oct 3, 2026
Merged

max-sixty merged 3 commits into
mainfrom
codex/environment-overlay-validation

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

One invalid environment override currently discards the entire environment layer. Validate each independent setting against the same file configuration, retaining valid overrides and attributing warnings only to rejected settings.

Custom-column fields form one setting, including project-scoped columns, so a required template and its integer width are accepted together. Deprecated names migrate before type selection. Valid environment values can repair an empty worktree path while unrelated invalid overrides are rejected. Typed validation issues identify their setting paths, and the loader preserves the current structured config diagnostics.

Validation: the required pre-merge gate passed 5,058 tests with one skipped, plus lint, doctests, and documentation generation. Real CLI regressions cover merged system/user layers, mixed valid/invalid overrides, lower-layer repairs, and project-scoped compound settings. Documentation sync passes.

This was written by Codex on behalf of max-sixty

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

test_list_config_env_deprecated_type_mismatch_drops_layer was renamed and no longer calls assert_cmd_snapshot!, but tests/snapshots/integration__integration_tests__list_config__list_config_env_deprecated_type_mismatch_drops_layer.snap is still in the tree. The Linux test job runs cargo insta test ... --unreferenced reject (see the 🧪 Full test suite step in ci.yaml), so that orphan will fail it. Delete the file. The setup_snapshot_settings / settings.bind wrapper left in that test and in test_project_custom_column_env_fields_are_atomic is also unused now, since neither test takes a snapshot.

codecov/patch is failing on three uncovered lines in src/config/user/mod.rs:

  • the if paths.is_empty() { continue; } skip in env_override_units
  • the _ => EnvOverrideKey::MultiPathVar(var.name.clone()) arm in the same function
  • the let Ok(..) = deserialize_validation_issues(&file_table) else { return; } guard in apply_env_vars

The last one is documented as an invariant guard that shouldn't be reachable. For MultiPathVar, I couldn't find a deprecation rule that turns one env leaf into several settings. If none exists, the enum variant and the BTreeSet reduction around it may not need to exist either. AGENTS.md requires explicit approval to merge with codecov/patch red, so these lines need either a test that reaches them or that approval.

@max-sixty
max-sixty merged commit 27d12e0 into main Oct 3, 2026
37 checks passed
@max-sixty
max-sixty deleted the codex/environment-overlay-validation branch October 3, 2026 03:44
max-sixty pushed a commit that referenced this pull request Nov 5, 2026
…wt list (#4358)

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.

---------

Co-authored-by: worktrunk-bot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants