From 604d9edf06b02edab83b1a1a993e7ff3f4e2fb97 Mon Sep 17 00:00:00 2001 From: Sylvain <1552102+sgaunet@users.noreply.github.com> Date: Fri, 20 Mar 2026 12:24:27 +0100 Subject: [PATCH] fix(config): handle empty YAML config files with decoder yaml.NewDecoder.Decode returns io.EOF for empty input unlike yaml.Unmarshal which returns nil. Treat io.EOF as valid (use defaults). Closes #78 --- pkg/config/config.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 8c4ba3c..ca2cad9 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -56,8 +56,10 @@ package config import ( "bytes" + "errors" "flag" "fmt" + "io" "os" "path/filepath" "strings" @@ -287,7 +289,7 @@ func loadConfigFile(config *Config, configFile string) error { decoder := yaml.NewDecoder(bytes.NewReader(data)) decoder.KnownFields(true) - if err := decoder.Decode(config); err != nil { + if err := decoder.Decode(config); err != nil && !errors.Is(err, io.EOF) { return fmt.Errorf("failed to parse YAML config: %w", err) }