Skip to content

Commit 9dbfc60

Browse files
authored
improve wasm error message (#3781)
1 parent 5a7e65f commit 9dbfc60

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

internal/fnruntime/wasmtime.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,12 @@ func (f *WasmtimeFn) Run(r io.Reader, w io.Writer) error {
152152
resultStr := fmt.Sprintf("%s", result)
153153
resultStr = resultStr[2 : len(resultStr)-1]
154154
// Try to parse the output as yaml.
155-
if _, err = yaml.Parse(resultStr); err != nil {
156-
return errors.New(resultStr)
155+
resourceListOutput, err := yaml.Parse(resultStr)
156+
if err != nil {
157+
return fmt.Errorf("error parsing output resource list %q: %w", resultStr, err)
158+
}
159+
if resourceListOutput.GetKind() != "ResourceList" {
160+
return fmt.Errorf("invalid resource list output from wasm library; got %q", resultStr)
157161
}
158162
if _, err = w.Write([]byte(resultStr)); err != nil {
159163
return fmt.Errorf("unable to write the output resource list: %w", err)

0 commit comments

Comments
 (0)