all repos — searchix @ 64881323e89d6d9b96865a5fa6f2150b826683db

Search engine for NixOS, nix-darwin, home-manager and NUR users

feat: error on non-matching configuration entries
Alan Pearce alan@alanpearce.eu
Fri, 17 May 2024 16:45:47 +0200
commit

64881323e89d6d9b96865a5fa6f2150b826683db

parent

8805c25adece20e4bee90faf0052804a3bfbab32

1 files changed, 5 insertions(+), 0 deletions(-)

jump to
M internal/config/config.gointernal/config/config.go
@@ -191,11 +191,16 @@ } 		defer f.Close()
 
 		dec := toml.NewDecoder(f)
+		dec.DisallowUnknownFields()
 		err = dec.Decode(&config)
 		if err != nil {
 			var tomlError *toml.DecodeError
 			if errors.As(err, &tomlError) {
 				return nil, errors.WithMessage(err, tomlError.Error())
+			}
+			var missingConfigError *toml.StrictMissingError
+			if errors.As(err, &missingConfigError) {
+				return nil, errors.Errorf("unexpected config: %s", missingConfigError.String())
 			}
 
 			return nil, errors.Wrap(err, "config error")