Skip to content

Commit

Permalink
Use yaml.UnmarshalStrict (#55)
Browse files Browse the repository at this point in the history
## 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: #55
  • Loading branch information
benjaminjkraft authored Aug 23, 2021
1 parent 3746ecd commit 6689d5a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion generate/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 6689d5a

Please sign in to comment.