Repository navigation
Reject owner without repo in notification and search tools - #3916
Open
mohitmishra786 wants to merge 1 commit into
Open
mohitmishra786 wants to merge 1 commit into
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
Contributor
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) { |
|
Bnans |
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
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.