Repository navigation
Reject owner without repo in notification and search tools - #3916
mohitmishra786 wants to merge 1 commit into
Conversation
list_notifications, mark_all_notifications_read, search_issues and search_pull_requests only scope to a repository when both owner and repo are set. A lone owner or repo was dropped and the call acted on all repositories; for mark_all_notifications_read that marks every notification as read. Return an error when only one of the two is given. The search tools still accept them when the query already has a repo: qualifier, since the query filter is used in that case. Fixes github#3915
There was a problem hiding this comment.
🟡 Changes recommended
The repository-filter check incorrectly matches repo: inside quoted label values, bypassing validation and silently dropping the owner scope in both search tools; the qualifier detection needs correction and regression coverage.
1 open issue
What changed in this PR
This PR addresses #3915 by rejecting incomplete repository parameters in notification and search tools, preventing calls from silently acting across repositories.
Changes:
- Adds shared validation requiring
ownerandrepotogether. - Applies validation to both notification tools and search preparation, preserving the intended exception for queries with a
repo:qualifier. - Updates regression tests for incomplete parameters and query-filter precedence.
| File | Description |
|---|---|
pkg/github/search_utils.go |
Validates repository parameter pairs during search preparation. |
pkg/github/pullrequests_test.go |
Expects errors for incomplete pull request search parameters. |
pkg/github/params.go |
Adds the shared owner/repository pair validator. |
pkg/github/notifications.go |
Rejects incomplete repository scope in both notification handlers. |
pkg/github/notifications_test.go |
Tests owner-only and repository-only notification calls. |
pkg/github/issues_test.go |
Tests incomplete search parameters and the query-filter exception. |
Review effort: Balanced (adaptive)
|
|
||
| if input.Owner != "" && input.Repo != "" && !hasRepoFilter(query) { | ||
| query = fmt.Sprintf("repo:%s/%s %s", input.Owner, input.Repo, query) | ||
| if !hasRepoFilter(query) { |
There was a problem hiding this comment.
The quoted case is real, but it comes from hasFilter and predates this PR. On main, prepareSearchArgs with owner: "octocat", repo: "hello" and query: label:"repo:octocat/project" bug already returns is:issue label:"repo:octocat/project" bug without the repo:octocat/hello scope. The regex (^|\s|\W)repo:\S+ treats the " as a boundary. This PR doesn't change which queries count as having a repo filter; it only stops dropping a lone owner or repo when there isn't one.
Making hasFilter skip quoted text would also change is: and type: detection, so I'd rather keep it out of this PR and send it separately.
|
Bnans |

Summary
Return an error when
owneris given withoutrepo(or the reverse) inlist_notifications,mark_all_notifications_read,search_issuesandsearch_pull_requests, instead of silently acting on all repositories.Why
These tools only scope to a repository when both values are set. A lone
ownerwas dropped, somark_all_notifications_read {"owner":"o"}marked every notification as read and the search tools searched everywhere. Details and request logs are in the issue.Fixes #3915
What changed
checkOwnerRepoPairinparams.goand call it in the two notification handlers and inprepareSearchArgs.owner/repowhen the query already has arepo:qualifier, since the query filter is used then and those calls work today.repo:qualifier.MCP impact
Schemas are unchanged. Calls with only one of
owner/reponow return a tool error instead of running unscoped.Prompts tested (tool changes only)
owner): now returns an error instead of marking all notifications read.owner: now returns an error instead of an unscoped search.Security / limits
Prevents a write from acting on a wider scope than the caller asked for.
Tool renaming
deprecated_tool_aliases.goLint & tests
./script/lint./script/testThe new cases fail on unmodified main and pass with this change.
Docs
script/generate-docsproduces no changes; tool descriptions are unchanged.Skills
notification-triage,issue-backlog-triage,issue-authoringandrelease-preparationalready pass bothownerandrepoor arepo:qualifier, so no skill update is needed.