From 579107cf2e243e1c8a49e793baa9ca607bad1f13 Mon Sep 17 00:00:00 2001 From: Rober Morales-Chaparro Date: Sun, 3 Dec 2017 14:15:40 +0100 Subject: [PATCH 1/2] Improve error message in case invalid env var found If you set an env var with non-yaml content but accidentally collides with a possible configuration env var,... The current error is ```configuration error: error parsing /etc/docker/registry/config.yml: yaml: unmarshal errors: line 1: cannot unmarshal !!str `tcp://1...` into configuration.Parameters``` With this change we can see at least which is the problematic env var. Some orchestrators such as docker-compose set env vars on top on user env vars, so debugging can be tricky if you are not passing vars, and the error is pointing you to a problably valid config file. Signed-off-by: Rober Morales-Chaparro Signed-off-by: Rober Morales-Chaparro --- configuration/parser.go | 1 + 1 file changed, 1 insertion(+) diff --git a/configuration/parser.go b/configuration/parser.go index 934a942a..1306b0c2 100644 --- a/configuration/parser.go +++ b/configuration/parser.go @@ -206,6 +206,7 @@ func (p *Parser) overwriteStruct(v reflect.Value, fullpath string, path []string fieldVal := reflect.New(sf.Type) err := yaml.Unmarshal([]byte(payload), fieldVal.Interface()) if err != nil { + logrus.Warnf("Error parsing environment variable %s", fullpath) return err } field.Set(reflect.Indirect(fieldVal)) From 4f173262e4d480e9701ff0f3994f90fdc1f1f1ae Mon Sep 17 00:00:00 2001 From: Rober Morales-Chaparro Date: Sun, 25 Mar 2018 12:40:48 +0200 Subject: [PATCH 2/2] patch-1 - adding more info to the error message Signed-off-by: Rober Morales-Chaparro Signed-off-by: Rober Morales-Chaparro --- configuration/parser.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration/parser.go b/configuration/parser.go index 1306b0c2..25023092 100644 --- a/configuration/parser.go +++ b/configuration/parser.go @@ -206,7 +206,7 @@ func (p *Parser) overwriteStruct(v reflect.Value, fullpath string, path []string fieldVal := reflect.New(sf.Type) err := yaml.Unmarshal([]byte(payload), fieldVal.Interface()) if err != nil { - logrus.Warnf("Error parsing environment variable %s", fullpath) + logrus.Warnf("Error parsing environment variable %s: %s", fullpath, err) return err } field.Set(reflect.Indirect(fieldVal))