@@ -36,6 +36,14 @@ type InputExpander interface {
3636 Expand (* JobInputs ) error
3737}
3838
39+ type InputInterpolationError struct {
40+ err error
41+ }
42+
43+ func (e * InputInterpolationError ) Error () string {
44+ return fmt .Sprintf ("failed to interpolate job inputs: %s" , e .err .Error ())
45+ }
46+
3947const (
4048 JobInputContentTypeNameString JobInputContentTypeName = "string"
4149 JobInputContentTypeNameNumber JobInputContentTypeName = "number"
@@ -211,12 +219,12 @@ func (i *JobInputs) Expand(text string) (string, error) {
211219
212220 expr , err := moa .ParseTemplate (text )
213221 if err != nil {
214- return "" , err
222+ return "" , & InputInterpolationError { err : err }
215223 }
216224
217- result , err := i .evaluator .Eval (expr )
225+ result , err := i .evaluator .Eval (text , expr )
218226 if err != nil {
219- return "" , err
227+ return "" , & InputInterpolationError { err : err }
220228 }
221229
222230 if result .HasMarks (expression .Sensitive ) {
@@ -234,7 +242,18 @@ func ExpandInputs(inputs *JobInputs, v any) error {
234242 if rv .Kind () != reflect .Struct {
235243 return fmt .Errorf ("expected struct, got %s" , rv .Kind ())
236244 }
237- return processStruct (inputs , rv )
245+
246+ err := processStruct (inputs , rv )
247+ if err != nil {
248+ e := & InputInterpolationError {}
249+ if errors .As (err , & e ) {
250+ return e
251+ }
252+
253+ return err
254+ }
255+
256+ return nil
238257}
239258
240259//nolint:gocognit
0 commit comments