Skip to content

Commit

Permalink
Merge pull request #292 from compose-spec/fix-interpolation-errors-ou…
Browse files Browse the repository at this point in the history
…tput

Fix interpolation error msg output
  • Loading branch information
ulyssessouza authored Jul 29, 2022
2 parents 1daf3e9 + 4bfef4b commit f1f5433
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion interpolation/interpolation.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func newPathError(path Path, err error) error {
return nil
case *template.InvalidTemplateError:
return errors.Errorf(
"invalid interpolation format for %s: %#v. You may need to escape any $ with another $",
"invalid interpolation format for %s.\nYou may need to escape any $ with another $.\n%s",
path, err.Template)
default:
return errors.Wrapf(err, "error while interpolating %s", path)
Expand Down
8 changes: 5 additions & 3 deletions interpolation/interpolation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ func TestInvalidInterpolation(t *testing.T) {
},
}
_, err := Interpolate(services, Options{LookupValue: defaultMapping})
assert.Error(t, err, `invalid interpolation format for servicea.image: "${". You may need to escape any $ with another $`)
assert.Error(t, err, `invalid interpolation format for servicea.image.
You may need to escape any $ with another $.
${`)
}

func TestInterpolateWithDefaults(t *testing.T) {
Expand Down Expand Up @@ -131,8 +133,8 @@ func TestValidUnexistentInterpolation(t *testing.T) {
}

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

for _, testcase := range testcases {
Expand Down

0 comments on commit f1f5433

Please sign in to comment.