Skip to content

Commit f1f5433

Browse files
authored
Merge pull request #292 from compose-spec/fix-interpolation-errors-output
Fix interpolation error msg output
2 parents 1daf3e9 + 4bfef4b commit f1f5433

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

interpolation/interpolation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func newPathError(path Path, err error) error {
115115
return nil
116116
case *template.InvalidTemplateError:
117117
return errors.Errorf(
118-
"invalid interpolation format for %s: %#v. You may need to escape any $ with another $",
118+
"invalid interpolation format for %s.\nYou may need to escape any $ with another $.\n%s",
119119
path, err.Template)
120120
default:
121121
return errors.Wrapf(err, "error while interpolating %s", path)

interpolation/interpolation_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ func TestInvalidInterpolation(t *testing.T) {
7373
},
7474
}
7575
_, err := Interpolate(services, Options{LookupValue: defaultMapping})
76-
assert.Error(t, err, `invalid interpolation format for servicea.image: "${". You may need to escape any $ with another $`)
76+
assert.Error(t, err, `invalid interpolation format for servicea.image.
77+
You may need to escape any $ with another $.
78+
${`)
7779
}
7880

7981
func TestInterpolateWithDefaults(t *testing.T) {
@@ -131,8 +133,8 @@ func TestValidUnexistentInterpolation(t *testing.T) {
131133
}
132134

133135
getFullErrorMsg := func(msg string) string {
134-
return fmt.Sprintf("invalid interpolation format for myservice.environment.TESTVAR: "+
135-
"\"required variable FOO is missing a value: %s\". You may need to escape any $ with another $", msg)
136+
return fmt.Sprintf("invalid interpolation format for myservice.environment.TESTVAR.\n"+
137+
"You may need to escape any $ with another $.\nrequired variable FOO is missing a value: %s", msg)
136138
}
137139

138140
for _, testcase := range testcases {

0 commit comments

Comments
 (0)