Repository navigation
feat: warn about unknown fields in config files at load time - #758
Merged
Merged
Conversation
Previously, unknown fields in config files (typos like `[commit-gen]` instead of `[commit-generation]`) were only shown via `wt config show`. Now warnings appear at config load time, helping users discover issues immediately. - Add `warn_unknown_fields()` function with per-process deduplication - Call from `UserConfig::load()` and `ProjectConfig::load()` - Check file content directly to avoid false positives from env vars - Only warn in main worktree for project config (where file is editable) Also fixes test configs that incorrectly used `worktree-path` in project configs (it's a user config field). Co-Authored-By: Claude <[email protected]>
Resolve conflict in deprecation.rs by adopting LazyLock pattern from main for both WARNED_DEPRECATED_PATHS and WARNED_UNKNOWN_PATHS statics. Co-Authored-By: Claude <[email protected]>
max-sixty
pushed a commit
that referenced
this pull request
Sep 16, 2026
…4145) ## Problem `ProjectConfig::load` gated its unknown-field warning on `is_main_worktree`, so the "key … will be ignored" message never fired outside the primary worktree. `wt merge` runs from the feature worktree, which is why the issue reads as a `wt merge` gap — but the suppression is the load path, not the command. `wt list`, `wt switch`, and every other command are equally silent there: ``` $ cd repo.feat && wt list # .config/wt.toml has [merge] (nothing) $ cd repo && wt list ▲ Project config has unknown field … (will be ignored) ``` `wt config show` warns from anywhere because it renders the same warnings through its own path (`collect_unknown_warnings`), which has no such gate. A bare repo, where every worktree is linked, never saw the warning at all. The consequence the issue describes follows from that: a project `[merge]` section is dropped at runtime with nothing said, so a machine carrying the `[projects."<id>"]` entry in user config merges one way and a fresh checkout of the same repo merges the other. ## Solution Drop the gate. The warning's fix — edit the tracked `.config/wt.toml`, or move the key into user config — is available from any worktree, so "only in main worktree where it's actionable" (#758) doesn't hold for this channel. The adjacent deprecation channel keeps its gate. That one's message points at `wt config update`, which does need the primary worktree, and `format_deprecation_details` already has separate linked-worktree handling for it. Emission stays deduped per path per process and still respects `suppress_warnings()`, so the picker and `wt list statusline` are unaffected. ## Testing `test_misplaced_project_key_warns_from_linked_worktree` writes `[merge]` into a linked worktree's project config and asserts the warning on `wt list` there. It fails on `main` ("got: ○ Showing 5 worktrees…") and passes with the change. It sits beside `test_unknown_project_key_warning_during_load`, its primary-worktree counterpart. The issue's own repro now warns before merging: ``` $ wt -C ../repro.feat merge --no-remove ▲ Project config has key merge which belongs in user config (will be ignored); to scope it to this repo, add it under [projects."<id>"] in user config ◎ Merging 1 commit to main @ 1552839 … ``` `cargo test --test integration` is green (2181 passed) apart from two `step_copy_ignored` cases that also fail on an unmodified tree in this sandbox — `AF_UNIX` bind is blocked and the umask is 0002. Same for `copy::tests::test_copy_dir_recursive_does_not_count_a_non_regular_file` under `--lib`. `cargo fmt --check` and `cargo clippy --all-targets` are clean. Closes #4144 — automated triage Co-authored-by: worktrunk-bot <[email protected]>
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.
Summary
[commit-gen]instead of[commit-generation]) were only shown viawt config showChanges
warn_unknown_fields()function with per-process deduplication (same pattern as deprecation warnings)UserConfig::load()andProjectConfig::load()Example output
Test plan
worktree-pathin project configs🤖 Generated with Claude Code