Refuse config keys that no setting has (closes #419)
check / check (push) Failing after 19m39s

config.Parse walks the file as written and fails on the first key that
matches no setting, naming its dotted path and line, so a typo in
exclude or prune_grace_period no longer falls back silently. Keys that a
${...} reference brings in are checked once smartconfig has filled it
in, and named without a line. YAML merge keys and a top-level env
section, which smartconfig reads, still load. config set refuses such a
key before writing. The key-to-field lookup moves from internal/cli to
config.SettingType so both use it.

Model: opus-5-5
This commit is contained in:
sneak committed 2026-11-11 01:23:51 +00:00
1 parent aae7fa17ae
commit 3a74896114
6 files changed
+341 -47

No files matched your search

+9 -1
View File
@@ -225,7 +225,7 @@ func TestConfigSetIndexUnderMissingKey(t *testing.T) {
// change after which the config would not load, with an error giving the
// reason, and leaves the file as it was. On the file `config init` writes,
// which does not load until storage_url is set, and on one that cannot be
// read here, only a value of the wrong type is refused.
// read here, only an unknown key or a value of the wrong type is refused.
func TestConfigSetKeepsFileThatWouldNotLoad(t *testing.T) {
t.Parallel()
@@ -237,6 +237,14 @@ func TestConfigSetKeepsFileThatWouldNotLoad(t *testing.T) {
value string
reason string
}{
// Keys that no setting has, on a config that loads and on one
// that does not.
{configWithoutRecipients, "nosuchkey", "1",
"no setting has this key: nosuchkey"},
{configWithoutRecipients, "snapshots.home.exlude", "/tmp",
"no setting has this key: snapshots.home.exlude"},
{defaultConfigText(macOS), "compression_lvl", "9",
"no setting has this key: compression_lvl"},
// Index 1 of the empty list the missing key gives.
{configWithoutRecipients, "age_recipients.1", testRecipient,
"index out of range"},