Skip to content
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

Plugin error handling #220

Closed
zosocanuck opened this issue Nov 27, 2022 · 3 comments
Closed

Plugin error handling #220

zosocanuck opened this issue Nov 27, 2022 · 3 comments

Comments

@zosocanuck
Copy link

Hi,

I'm testing a plugin prototype (based on notation-azure-kv) that will implement signature generator however when it comes to error handling I seem to be only obtaining the following generic error:

Error: describe-key command failed: xyz-plugin: ERROR: failed to decode json response: plugin not compliant

In cmd/xyz-plugin main.go I have:

if err := app.Run(os.Args); err != nil {
		var reer plugin.RequestError
		if !errors.As(err, &reer) {
			err = plugin.RequestError{
				Code: plugin.ErrorCodeGeneric,
				Err:  err,
			}
		}
		data, _ := json.Marshal(err)
		os.Stderr.Write(data)
		os.Exit(1)
	}

Within the actual runDescribeKey I'm returning a plugin.RequestError per the spec:

if err != nil {
			return nil, plugin.RequestError{
				Code: plugin.ErrorCodeValidation,
				Err:  errors.New("custom error message goes here: " + err.Error()),
			}
		}

Seems like the plugin handler in notation-go is not correctly handling the returned error?

@sajayantony
Copy link
Contributor

@JeyJeyGao
Copy link
Contributor

JeyJeyGao commented Jan 13, 2023

Hi Ivan @zosocanuck , notation-go package has been refactored. Looks like you were using plugin.RequestError which is the old version. After refactoring, it should be proto.RequestError, so could you try the notation-go RC.1 again? Please let us know if you still have issues.

Please try:

go get github.com/notaryproject/[email protected]
go mod tidy

then replace plugin.RequestError with proto.RequestError and try again.
You should also use Notation CLI RC.1 to test your plugin.

@zosocanuck
Copy link
Author

@JeyJeyGao Yes I'm using the latest RC.1 and turns out I was unexpectedly sending log information via os.Stdout, which was causing the issue, and hence would explain the error about the plugin not being compliant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

3 participants