Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2.2k
cli-plugins/manager: various fixes and deprecations#6237
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
54367b3549d39a1cc698c7146021d789bac50963ac5876b29513ceeeFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -23,11 +23,6 @@ func (e *pluginError) Error() string { | ||||||||||||
| return e.cause.Error() | ||||||||||||
| } | ||||||||||||
| // Cause satisfies the errors.causer interface for pluginError. | ||||||||||||
| func (e *pluginError) Cause() error { | ||||||||||||
| return e.cause | ||||||||||||
| } | ||||||||||||
| // Unwrap provides compatibility for Go 1.13 error chains. | ||||||||||||
| func (e *pluginError) Unwrap() error { | ||||||||||||
| return e.cause | ||||||||||||
| @@ -41,14 +36,11 @@ func (e *pluginError) MarshalText() (text []byte, err error) { | ||||||||||||
| // wrapAsPluginError wraps an error in a pluginError with an | ||||||||||||
| // additional message. | ||||||||||||
| func wrapAsPluginError(err error, msg string) error { | ||||||||||||
CopilotAI | ||||||||||||
| funcwrapAsPluginError(errerror, msgstring) error { | |
| funcwrapAsPluginError(errerror, msgstring) error { | |
| iferr==nil { | |
| returnnil | |
| } |
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.
Nope; that's exactly the reason I don't want it; the caller should check if there's an error to wrap. Silently discarding such mistakes leads to subtle bugs.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| package manager | ||
| import ( | ||
| "encoding/json" | ||
| "errors" | ||
| "testing" | ||
| "gotest.tools/v3/assert" | ||
| is "gotest.tools/v3/assert/cmp" | ||
| ) | ||
| func TestPluginMarshal(t *testing.T) { | ||
| const jsonWithError = `{"Name":"some-plugin","Err":"something went wrong"}` | ||
| const jsonNoError = `{"Name":"some-plugin"}` | ||
| tests := []struct { | ||
| doc string | ||
| error error | ||
| expected string | ||
| }{ | ||
| { | ||
| doc: "no error", | ||
| expected: jsonNoError, | ||
| }, | ||
| { | ||
| doc: "regular error", | ||
| error: errors.New("something went wrong"), | ||
| expected: jsonWithError, | ||
| }, | ||
| { | ||
| doc: "custom error", | ||
| error: newPluginError("something went wrong"), | ||
| expected: jsonWithError, | ||
| }, | ||
| } | ||
| for _, tc := range tests { | ||
| t.Run(tc.doc, func(t *testing.T) { | ||
| actual, err := json.Marshal(&Plugin{Name: "some-plugin", Err: tc.error}) | ||
| assert.NilError(t, err) | ||
| assert.Check(t, is.Equal(string(actual), tc.expected)) | ||
| }) | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
CopilotAIAug 4, 2025
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.
The function
wrapAsPluginErrorno longer checks for nil errors, but the function body will panic iferris nil when callingfmt.Errorf("%s: %w", msg, err). Either add a nil check or ensure all callers handle nil errors before calling this function.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 don't see how it would panic. But sure, let me add a test-case to make sure it doesn't