fix(config): migrate deprecated keys in env vars and inline tables - #3158
Merged
Conversation
Extends the `--config-set` deprecation migration (#3152) to the two remaining places a deprecated config key could slip through unmigrated. Env-var layer: `migrate_env_overlay()` runs the assembled `WORKTRUNK_*` overlay through the same `migrate_content()` config files and `--config-set` use, before the deep-merge, so `WORKTRUNK__MERGE__NO_FF=true` takes effect as `merge.ff` instead of falling through as an unknown field. Migrating before the merge keeps env winning over a lower layer's canonical key. A side effect, now documented and tested: a deprecated env var whose canonical target is a non-bool field, set to a type-mismatched value (`WORKTRUNK__COMMIT_GENERATION__COMMAND=42`), joins the existing whole-env-layer `LoadError::Env` drop instead of being silently ignored — the same contract a bad value in a canonical env var already follows. Inline-table form: `migrate_negated_bool_doc` resolved its section via `as_table_mut()`, which is `None` for an inline `merge = { no-ff = true }`, so the inline form was never migrated (and surfaced as a double unknown-field warning). It now handles both standard and inline tables, fixing config files, `--config-set`, and env at once. `remove_switch_picker_timeout_in` gets the same inline-`switch` handling so every `switch` sub-key rule is consistent, and the `DEPRECATION_RULES` ordering comment is corrected: the `[select]` rule's inline-to-standard conversion is no longer relied on, only its `timeout-ms` move. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
worktrunk-bot
approved these changes
Jun 22, 2026
Collaborator
|
Approved. One advisory check went red — The failure is a 180s timeout on The required |
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.
The gap
#3152 routed the
--config-setlayer through the deprecation-migration layer, but a deprecated config key could still slip through unmigrated in two other places. Both are now closed with the same mechanism (migrate_content).Env-var layer
migrate_env_overlay()runs the assembledWORKTRUNK_*overlay through the samemigrate_content()config files and--config-setuse, before the deep-merge. SoWORKTRUNK__MERGE__NO_FF=trueresolves to the deprecated keymerge.no-ffand now takes effect asmerge.ff=false, instead of falling through as an unknown field and being silently ignored. Migrating before the merge (not after) keeps the env value winning over a lower layer's canonical key, matching the layer precedence.One behavior edge, now documented on the function and pinned by a test: canonicalization surfaces a type mismatch the deprecated name hid.
WORKTRUNK__COMMIT_GENERATION__COMMAND=42migrates tocommit.generation.command = 42, which fails to deserialize (the field is a String), so the whole env layer is dropped with an attributedLoadError::Envwarning and file config is preserved — the same contract a type-mismatched value in a canonical env var already follows. Previously the unknown key was silently ignored and other env vars survived.Inline-table form
migrate_negated_bool_docresolved its section withas_table_mut(), which returnsNonefor an inlinemerge = { no-ff = true }, so the inline form was never migrated (and surfaced as a double unknown-field warning instead of a deprecation warning). It now branches on standard vs inline table, fixing config files,--config-set, and env at once — the inline shape is preserved (merge = { ff = false }).remove_switch_picker_timeout_inhad the sameas_table_mut()-on-switchlimitation, so it's given matching inline-switchhandling and now everyswitchsub-key rule is inline-aware. With that, theDEPRECATION_RULESordering comment is corrected: the[select]→[switch.picker]rule's inline-to-standardswitchconversion is no longer relied on by any rule; only itstimeout-msmove remains load-bearing.Tests
test_env_overlay_migrates_deprecated_key(fullEnvVar→ resolve → migrate path),test_migrate_negated_bool_inline_table.test_switch_env_var_migrates_deprecated_no_cd(cd-directive bug-catcher — reverting the fix re-adds the "Cannot change directory" line),test_list_config_env_deprecated_type_mismatch_drops_layer(the documented whole-layer-drop edge).test_warning_fires_iff_update_changesbattery (negated-bool inline, inline-switchtimeout-ms).