Skip to content

fix(config): coerce config set values and keep config get in lockstep - #96

Merged
jamesainslie merged 1 commit into
mainfrom
fix-config-set-type-coercion
Aug 12, 2026
Merged

jamesainslie merged 1 commit into
mainfrom
fix-config-set-type-coercion

Conversation

@jamesainslie

Copy link
Copy Markdown
Collaborator

Summary

Fixes #94.

  • dot config set delivered every value as a string, but most typed setters type-asserted the raw argument, so boolean and integer keys could never be set from the CLI (symlinks.backup, output.verbosity, operations.*, packages.*, doctor.*, experimental.*). Every boolean field now routes through toBool (which also tolerates surrounding whitespace), integer fields through a new toInt, and field names are validated before coercion so doctor.bogus is reported as an unknown field rather than a value error.
  • config get had drifted the other way: its getter map knew only 15 keys, so a freshly set key read back as "unknown config key". The getter map now covers the full settable surface and completion derives from it.
  • symlinks.backup_dir was offered by completion but rejected by the setter; it is now settable.

Tests

  • TestWriter_UpdateCoercesCLIStrings: every typed key set from its CLI string form, round-tripped through a real write/load.
  • TestConfigCommand_EveryCompletedKeyRoundTrips: walks getValidConfigKeys() and drives set -> load -> get for each, so the getter and setter surfaces cannot drift apart silently again.
  • Unparsable strings and unknown fields produce named errors.

Full suite green with race and coverage; golangci-lint clean.

dot config set delivers every value as a string, but most typed setters
type-asserted the raw argument, so boolean and integer keys could never
be set from the CLI (symlinks.backup, output.verbosity, doctor.*, and
friends all failed with "value must be bool"). Route every boolean
field through toBool, add toInt for the integer fields, and validate
field names before coercing so an unknown field is reported as unknown.

config get had drifted the other way: its hand-written getter map knew
only 15 keys, so a freshly set key read back as "unknown config key".
The getter map now covers the full settable surface, completion derives
from it, and a round-trip test walks getValidConfigKeys so the two
surfaces cannot drift apart silently again. symlinks.backup_dir, which
completion offered but the setter rejected, is now settable too.

Fixes #94
@jamesainslie
jamesainslie merged commit 53a2aed into main Aug 12, 2026
15 of 16 checks passed
@jamesainslie
jamesainslie deleted the fix-config-set-type-coercion branch August 12, 2026 17:30
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.

config set cannot set boolean keys: symlinks.backup true fails with "value must be bool"

1 participant