Skip to content

fix: accept deprecated files config key as lists - #545

Open
mvanhorn wants to merge 1 commit into
almeidapaulopt:mainfrom
mvanhorn:fix/512-files-lists-alias
Open

mvanhorn wants to merge 1 commit into
almeidapaulopt:mainfrom
mvanhorn:fix/512-files-lists-alias

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

On the root Data mapping only, the walker now treats files as a deprecated alias of lists, matching the key case-insensitively. When lists is absent, the key is renamed to lists and a warning is logged so Decode fills Data.Lists; when both are present and files is an empty mapping, an empty sequence, or a null scalar, that pair is removed and lists is kept, with a warning. A non-empty files value beside lists is left in place so the unknown-field error still fires. The name stays off the struct and out of the key lookup so a later save does not write it back, and nested mappings and other unknown root keys remain under the strict check. Configs written by v1 and v2 still contain a root key named files, often the empty mapping those releases generated. v3 refuses to start and exits with an unknown-field error that names files and suggests lists, so an upgrade crash-loops until that key is removed by hand. The provider now lives on Data as lists, and the YAML walker rejects any key that is not a field of the struct being decoded. files was still present when unknown keys were collected, so the loader never renamed it and never decoded its value into Data.Lists.

Testing: Gofmt -l reports no unformatted files among the edited sources. go vet reports no issues for the config package.

Fixes #512

On the root Data mapping only, the walker now treats files as a
deprecated alias of lists, matching the key case-insensitively. When
lists is absent, the key is renamed to lists and a warning is logged so
Decode fills Data.Lists; when both are present and files is an empty
mapping, an empty sequence, or a null scalar, that pair is removed and
lists is kept, with a warning. A non-empty files value beside lists is
left in place so the unknown-field error still fires. The name stays off
the struct and out of the key lookup so a later save does not write it
back, and nested mappings and other unknown root keys remain under the
strict check.

Fixes almeidapaulopt#512

This branch has not been deployed

No deployments
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.

Upgrade to v3 crash-loops on auto-generated v1/v2 config (files field now rejected)

1 participant