config set wrote every value as an unquoted YAML scalar, and config.Load reads the file into untyped YAML values before decoding it into config.Config. An access key 00112233 therefore loaded as 38043, a 32-digit secret as 1.2345678901234567e+31 and a hostname 007 as 7.
config set now looks the key up in config.Config by the fields' yaml tags, through the snapshots map and the lists. When the key is a string, the value is tagged !!str. The YAML encoder then leaves it unquoted if YAML would read it as a string anyway, and double-quotes it if YAML would read a number, a boolean or null. Every other key is written unquoted as before, so compression_level 9 stays a number.
What the diff does not show:
A value that is not valid UTF-8 is left untagged, because the encoder refuses it as !!str. It is written as base64 !!binary and loads back unchanged, as before.
A key that is not a field of config.Config, such as the env section the config loader reads, is still written unquoted.
Only the value being set gets the tag. A hand-written unquoted access_key_id: 00112233 already in the file still loads as 38043.
Judgement call: this reads the type by reflection over config.Config, which the Go style guide asks to use sparingly. The alternative, quoting every value whose text YAML would change, would also quote odd numbers such as compression_level 03 (loaded as 3 today) and make them fail to load.
Model: opus-5-5
Fixes https://git.eeqj.de/sneak/vaultik/issues/229.
`config set` wrote every value as an unquoted YAML scalar, and `config.Load` reads the file into untyped YAML values before decoding it into `config.Config`. An access key `00112233` therefore loaded as `38043`, a 32-digit secret as `1.2345678901234567e+31` and a hostname `007` as `7`.
`config set` now looks the key up in `config.Config` by the fields' yaml tags, through the `snapshots` map and the lists. When the key is a string, the value is tagged `!!str`. The YAML encoder then leaves it unquoted if YAML would read it as a string anyway, and double-quotes it if YAML would read a number, a boolean or null. Every other key is written unquoted as before, so `compression_level 9` stays a number.
What the diff does not show:
- A value that is not valid UTF-8 is left untagged, because the encoder refuses it as `!!str`. It is written as base64 `!!binary` and loads back unchanged, as before.
- A key that is not a field of `config.Config`, such as the `env` section the config loader reads, is still written unquoted.
- Only the value being set gets the tag. A hand-written unquoted `access_key_id: 00112233` already in the file still loads as `38043`.
Judgement call: this reads the type by reflection over `config.Config`, which the Go style guide asks to use sparingly. The alternative, quoting every value whose text YAML would change, would also quote odd numbers such as `compression_level 03` (loaded as 3 today) and make them fail to load.
Model: opus-5-5
internal/cli/config.go:595: tagging the value as a YAML string makes config set refuse any string value that is not valid UTF-8, with marshaling config: yaml: cannot marshal invalid UTF-8 data as !!str. Before this change such a value, for example a snapshot path or exclude pattern with a Latin-1 file name, was written as !!binary and loaded back unchanged. Acceptable: tag only values that are valid UTF-8, with a test that sets a non-UTF-8 path and loads it back.
internal/cli/config_test.go:117: the boolean case, s3.bucket set to true, also passes with the fix reverted, because an unquoted true loads back as the string true anyway. The test therefore covers no boolean-looking value that the fix changes. Acceptable: add a value that fails without the fix, such as True or FALSE, which load as true and false without it.
Model: opus-5-5
1. `internal/cli/config.go:595`: tagging the value as a YAML string makes `config set` refuse any string value that is not valid UTF-8, with `marshaling config: yaml: cannot marshal invalid UTF-8 data as !!str`. Before this change such a value, for example a snapshot path or exclude pattern with a Latin-1 file name, was written as `!!binary` and loaded back unchanged. Acceptable: tag only values that are valid UTF-8, with a test that sets a non-UTF-8 path and loads it back.
2. `internal/cli/config_test.go:117`: the boolean case, `s3.bucket` set to `true`, also passes with the fix reverted, because an unquoted `true` loads back as the string `true` anyway. The test therefore covers no boolean-looking value that the fix changes. Acceptable: add a value that fails without the fix, such as `True` or `FALSE`, which load as `true` and `false` without it.
Model: opus-5-5
config set wrote every value as an unquoted YAML scalar, and config.Load
reads the file through untyped YAML, so an access key 00112233 loaded as
38043 and a hostname 007 as 7.
config set now looks the key up in config.Config by the fields' yaml
tags. A string setting is tagged !!str, which the encoder quotes
wherever YAML would read a number or a boolean. Other settings stay
unquoted, so compression_level 9 is still a number. A value that is not
valid UTF-8 stays untagged: the encoder refuses it as !!str and writes
it as !!binary, which loads back unchanged.
Judgement call: the type comes from reflection over config.Config.
Quoting every value YAML would change avoids that, but would also quote
odd numbers such as compression_level 03 and make them fail to load.
Model: opus-5-5
internal/cli/config.go: a value that is not valid UTF-8 is no longer tagged, so it is written as !!binary again; TestConfigSetNonUTF8Path sets a Latin-1 snapshot path and checks that config.Load returns it unchanged.
internal/cli/config_test.go: added s3.region set to FALSE, which loads as false without the fix.
Model: opus-5-5
1. `internal/cli/config.go`: a value that is not valid UTF-8 is no longer tagged, so it is written as `!!binary` again; `TestConfigSetNonUTF8Path` sets a Latin-1 snapshot path and checks that `config.Load` returns it unchanged.
2. `internal/cli/config_test.go`: added `s3.region` set to `FALSE`, which loads as `false` without the fix.
Model: opus-5-5
Landing commit 85e5cf0, commit message: the body is 133 words, over the limit of about 120 words for a commit body. Acceptable: the same content in about 120 words or fewer, for example by shortening the judgement-call paragraph, which the PR body already carries in full.
Model: opus-5-5
1. Landing commit `85e5cf0`, commit message: the body is 133 words, over the limit of about 120 words for a commit body. Acceptable: the same content in about 120 words or fewer, for example by shortening the judgement-call paragraph, which the PR body already carries in full.
Model: opus-5-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Fixes #229.
config setwrote every value as an unquoted YAML scalar, andconfig.Loadreads the file into untyped YAML values before decoding it intoconfig.Config. An access key00112233therefore loaded as38043, a 32-digit secret as1.2345678901234567e+31and a hostname007as7.config setnow looks the key up inconfig.Configby the fields' yaml tags, through thesnapshotsmap and the lists. When the key is a string, the value is tagged!!str. The YAML encoder then leaves it unquoted if YAML would read it as a string anyway, and double-quotes it if YAML would read a number, a boolean or null. Every other key is written unquoted as before, socompression_level 9stays a number.What the diff does not show:
!!str. It is written as base64!!binaryand loads back unchanged, as before.config.Config, such as theenvsection the config loader reads, is still written unquoted.access_key_id: 00112233already in the file still loads as38043.Judgement call: this reads the type by reflection over
config.Config, which the Go style guide asks to use sparingly. The alternative, quoting every value whose text YAML would change, would also quote odd numbers such ascompression_level 03(loaded as 3 today) and make them fail to load.Model: opus-5-5
internal/cli/config.go:595: tagging the value as a YAML string makesconfig setrefuse any string value that is not valid UTF-8, withmarshaling config: yaml: cannot marshal invalid UTF-8 data as !!str. Before this change such a value, for example a snapshot path or exclude pattern with a Latin-1 file name, was written as!!binaryand loaded back unchanged. Acceptable: tag only values that are valid UTF-8, with a test that sets a non-UTF-8 path and loads it back.internal/cli/config_test.go:117: the boolean case,s3.bucketset totrue, also passes with the fix reverted, because an unquotedtrueloads back as the stringtrueanyway. The test therefore covers no boolean-looking value that the fix changes. Acceptable: add a value that fails without the fix, such asTrueorFALSE, which load astrueandfalsewithout it.Model: opus-5-5
fb1e4f9242to85e5cf0bf2internal/cli/config.go: a value that is not valid UTF-8 is no longer tagged, so it is written as!!binaryagain;TestConfigSetNonUTF8Pathsets a Latin-1 snapshot path and checks thatconfig.Loadreturns it unchanged.internal/cli/config_test.go: addeds3.regionset toFALSE, which loads asfalsewithout the fix.Model: opus-5-5
85e5cf0, commit message: the body is 133 words, over the limit of about 120 words for a commit body. Acceptable: the same content in about 120 words or fewer, for example by shortening the judgement-call paragraph, which the PR body already carries in full.Model: opus-5-5