-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve wasm errors #3830
Improve wasm errors #3830
Conversation
internal/fnruntime/wasmtime.go
Outdated
@@ -154,17 +154,33 @@ func (f *WasmtimeFn) Run(r io.Reader, w io.Writer) error { | |||
// Try to parse the output as yaml. | |||
resourceListOutput, err := yaml.Parse(resultStr) | |||
if err != nil { | |||
return fmt.Errorf("error parsing output resource list %q: %w", resultStr, err) | |||
additionalErrorMessage, err2 := retrieveError(f, resourceList) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use a more descriptive name here than err2
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I gave it another shot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for working on this and for providing more detailed context and investigation in the issue as well. This is a great change. I have some small nits below.
One last thing, could you update the PR description to add what the error output looked like before, and what this PR changes it to? (So that someone without context can immediately understand the behavior change.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Will defer to @mortent to make sure his comments are addressed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thanks for contributing!
Currently WASM compiled functions panic when attempting to return an error.
Also, the error returned is often not meaningful without retrieving the
resourceList.Results
and showing them to the user.This change builds on this PR GoogleContainerTools/kpt-functions-catalog#978 to benefit from the additional function, introduced to allow retrieving and showing
resourceList.Results
to the user.Both that and this PR should solve #3822.
Shortcomings:
resourceList.Results
entries to the entry introduced by the last function. In the PR I assume that entries with Severity "error" result in the function failing, and that all "error" entries are relevantPreviously, output would be like this:
With these changes, including the PR for the functions:
The key message here is
key "params" not in dict
, as in my example I had a starlark function that tries to accessparams
when it is not available.