Show error in logs if passing invalid flags in yaml (#9033)

* Show error in logs if passing invalid flags in yaml

The YAML configs pass if an invalid flag is set, this causes frustration
because the flag could have been mispelled causing a huge mystery.

This will strictly check if the flags are deserialized, if a flag
doesn't exist, it will error out as a Fatal error with appropriate
reasoning which flag is wrong.

* Fix review comments to make some of them non-fatal

* Make yaml.TypeError a pointer

* Remove UnmarshalStrict from spectests since they use a different YAML package

Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
This commit is contained in:
Mohamed Mansour
2021-07-31 20:26:24 -07:00
committed by GitHub
parent 0c1fc65604
commit 47c28e6cd6
4 changed files with 19 additions and 7 deletions

View File

@@ -36,7 +36,7 @@ func main() {
log.Fatalf("Failed to read file %s: %v", inFile, err)
}
data := make(KeyPairs, 0)
if err := yaml.Unmarshal(in, &data); err != nil {
if err := yaml.UnmarshalStrict(in, &data); err != nil {
log.Fatalf("Failed to unmarshal yaml: %v", err)
}