From 6689d5a0092bc16cbece9fe94ced3e7bc2f2266e Mon Sep 17 00:00:00 2001 From: Ben Kraft Date: Mon, 23 Aug 2021 15:52:08 -0700 Subject: [PATCH] Use yaml.UnmarshalStrict (#55) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 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 --- generate/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generate/config.go b/generate/config.go index 364891a..ad93372 100644 --- a/generate/config.go +++ b/generate/config.go @@ -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) }