Reject unknown fields in mapping configuration#695
Closed
highlyavailable wants to merge 1 commit into
Closed
Conversation
InitFromYAMLString used yaml.Unmarshal, which silently ignores keys that do not match a struct field. A typo in a mapping or defaults key would be dropped without warning, so the config would quietly behave differently than intended. Switch to yaml.UnmarshalStrict so unknown keys are reported as an error. The deprecated timer_type, buckets and quantiles keys are still accepted, since the alias structs used by the custom unmarshalers already declare them. Signed-off-by: highlyavailable <pwbryant1@gmail.com>
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
InitFromYAMLStringusedyaml.Unmarshal, which silently drops keys that don't match a struct field. A typo in a mapping ordefaultskey would be ignored, so the config quietly behaved differently than intended (see #544).This switches to
yaml.UnmarshalStrictso unknown keys are reported as an error. The deprecatedtimer_type,bucketsandquantileskeys still work, since the alias structs the custom unmarshalers use already declare them. Added tests for an unknown key at the top level, indefaults, and in a mapping.As noted in the issue this is technically a breaking change, in the sense that a config which silently did the wrong thing now fails loudly, so it probably wants a
[CHANGE]changelog line at release.Closes #546