Draft
Conversation
Signed-off-by: DharunMR <maddharun56@gmail.com>
Signed-off-by: DharunMR <maddharun56@gmail.com>
Member
evankanderson
left a comment
There was a problem hiding this comment.
You've wandered into a little bit of magic here to make the CLI and API usage easier in the common case. 😁
|
|
||
| if in.GetContext() == nil || in.GetContext().GetProvider() == "" { | ||
| return nil, util.UserVisibleError(codes.InvalidArgument, "provider name must be specified when listing repositories") | ||
| } |
Member
There was a problem hiding this comment.
This doesn't seem to crash or cause a problem today:
$ ./bin/minder repo list
OWNER │ NAME │ PROVIDER │ UPSTREAM ID
────────────────────┼───────────┼─────────────────────────────────┼────────────────
a-random-sandbox │ colorls │ github-app-a-random-sandbox │ 693510024
├───────────┤ ├────────────────
│ doitlive │ │ 693507178
Member
There was a problem hiding this comment.
With curl, in case you think there's some magic in the CLI:
$ curl -H "Authorization: Bearer $(jq -r .access_token ~/.config/minder/127.0.0.1_8090.json)" 'http://localhost:8080/api/v1/repositories/provider/' | jq '.results[] | .name'
...
"colorls"
"doitlive"
Comment on lines
+315
to
+317
| if in.GetContext() == nil || in.GetContext().GetProvider() == "" { | ||
| return nil, util.UserVisibleError(codes.InvalidArgument, "provider name must be specified when deleting a repository by name") | ||
| } |
Member
There was a problem hiding this comment.
This doesn't seem to crash today:
$ ./bin/minder repo delete -n a-random-sandbox/.github
Successfully deleted repo with name: a-random-sandbox/.github| _ *pb.ListRepositoriesRequest) (*pb.ListRepositoriesResponse, error) { | ||
| in *pb.ListRepositoriesRequest) (*pb.ListRepositoriesResponse, error) { | ||
|
|
||
| if in.GetContext() == nil || in.GetContext().GetProvider() == "" { |
Member
There was a problem hiding this comment.
GetProvider() already handles being called on a nil *Context -- using the proto getters will automatically handle empty / missing fields by returning the default (zero) value.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enforces explicit providerName validation directly on the RPC request payload for DeleteRepositoryByName. This prevents the panic: nil pointer dereference and stops ambiguous/non-deterministic deletions when a user omits the provider flag.
Added missing get repo testcases