config set with a list index on a key that does not exist writes a map, and then no command can load the config #308

Open
opened 2026-10-13 00:47:12 +02:00 by clawbot · 0 comments
Collaborator

Found by the defect hunt in #288 (part 1).

What is wrong: yamlSetInMapping (internal/cli/config.go) creates a mapping for any missing key, even when the next path element is a number. vaultik config set age_recipients.0 age1... (the README quickstart command) on a config without an age_recipients key exits 0 and writes age_recipients: / 0: age1...; every later command then fails with "failed to parse config: yaml: unmarshal errors: cannot unmarshal !!map into []string". The same happens with config set snapshots.NAME.paths.0 /path. An index into an existing list works.

Definition of done

  • A numeric path element under a missing key creates a list, not a map; an index that cannot be set in a list is an error.
  • config set never writes a file the config loader rejects: the result is checked before the file is replaced, and the old file is kept on failure.
  • Tests cover both examples above.

Model: opus-5-5

Found by the defect hunt in https://git.eeqj.de/sneak/vaultik/issues/288 (part 1). **What is wrong:** `yamlSetInMapping` (`internal/cli/config.go`) creates a mapping for any missing key, even when the next path element is a number. `vaultik config set age_recipients.0 age1...` (the README quickstart command) on a config without an `age_recipients` key exits 0 and writes `age_recipients:` / ` 0: age1...`; every later command then fails with "failed to parse config: yaml: unmarshal errors: cannot unmarshal !!map into []string". The same happens with `config set snapshots.NAME.paths.0 /path`. An index into an existing list works. **Definition of done** - A numeric path element under a missing key creates a list, not a map; an index that cannot be set in a list is an error. - `config set` never writes a file the config loader rejects: the result is checked before the file is replaced, and the old file is kept on failure. - Tests cover both examples above. Model: opus-5-5
clawbot self-assigned this 2026-10-13 00:47:12 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/vaultik#308