Use yaml.UnmarshalStrict (#55)

## Summary:
As Mark pointed out in a review where I realized that the *example* had
a bogus config key (which I hadn't noticed earlier because it was just
using the default value), we should probably do a strict-unmarshal;
there's no reason you should have random extra keys in your config and
if you do it's probably a mistake.  (Or maybe you're running a too-old
version of genqlient for your codebase, which you probably also want to
know.)  Now we do.

## Test plan:
- `make check`
- in webapp, `go mod edit -replace github.com/Khan/genqlient=../genqlient`
  then `make genqlient` produces no diffs (except go.mod/go.sum).


Author: benjaminjkraft

Reviewers: dnerdy, aberkan, csilvers, MiguelCastillo

Required Reviewers: 

Approved by: dnerdy

Checks:  Test (1.17),  Test (1.16),  Test (1.15),  Test (1.14),  Test (1.13),  Lint,  Test (1.17),  Test (1.16),  Test (1.15),  Test (1.14),  Test (1.13),  Lint

Pull request URL: https://github.com/Khan/genqlient/pull/55
This commit is contained in:
Ben Kraft
2021-08-23 15:52:08 -07:00
committed by GitHub
parent 3746ecd063
commit 6689d5a009
+1 -1
View File
@@ -120,7 +120,7 @@ func ReadAndValidateConfig(filename string) (*Config, error) {
return nil, errorf(nil, "unreadable config file %v: %v", filename, err)
}
err = yaml.Unmarshal(text, &config)
err = yaml.UnmarshalStrict(text, &config)
if err != nil {
return nil, errorf(nil, "invalid config file %v: %v", filename, err)
}