Skip to content

Fixed Repo delete by name#6336

Draft
DharunMR wants to merge 2 commits intomindersec:mainfrom
DharunMR:fix-repo-delete-by-name
Draft

Fixed Repo delete by name#6336
DharunMR wants to merge 2 commits intomindersec:mainfrom
DharunMR:fix-repo-delete-by-name

Conversation

@DharunMR
Copy link
Copy Markdown
Contributor

@DharunMR DharunMR commented Apr 10, 2026

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

Signed-off-by: DharunMR <maddharun56@gmail.com>
@DharunMR DharunMR requested a review from a team as a code owner April 10, 2026 19:09
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 10, 2026

Coverage Status

coverage: 59.456% (+0.1%) from 59.314% — DharunMR:fix-repo-delete-by-name into mindersec:main

Signed-off-by: DharunMR <maddharun56@gmail.com>
Copy link
Copy Markdown
Member

@evankanderson evankanderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() == "" {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@DharunMR DharunMR marked this pull request as draft April 14, 2026 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get/Delete Repo by name endpoints may match more than one repo if we add support for multiple repo providers

3 participants