-
Notifications
You must be signed in to change notification settings - Fork 26
Fix panic in api-key delete #3339
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,7 +47,7 @@ func (c *command) delete(cmd *cobra.Command, args []string) error { | |
|
|
||
| errs := multierror.Append(err, c.deleteKeysFromKeyStore(deletedIds)) | ||
| if errs.ErrorOrNil() != nil { | ||
| return errors.NewErrorWithSuggestions(err.Error(), errors.ApiKeyNotFoundSuggestions) | ||
| return errors.NewErrorWithSuggestions(errs.Error(), errors.ApiKeyNotFoundSuggestions) | ||
|
Comment on lines
48
to
+50
|
||
| } | ||
|
|
||
| return nil | ||
|
|
||
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.
errscan include failures fromdeleteKeysFromKeyStore(which ultimately callsConfig.Save()), not just API-key-not-found/forbidden errors. Wrapping all aggregated errors witherrors.ApiKeyNotFoundSuggestionswill produce misleading guidance when the underlying failure is a local config/keystore write error. Consider branching on the error source (e.g., only attachApiKeyNotFoundSuggestionswhen the delete API call failed; otherwise return/wrap the config-save error with a more relevant message/suggestions).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.
This is a valid point, but the purpose of the PR is just to triage the panic.