Skip to content

Reject owner without repo in notification and search tools - #3916

Open
mohitmishra786 wants to merge 1 commit into
github:mainfrom
mohitmishra786:3915-owner-repo-together
Open

mohitmishra786 wants to merge 1 commit into
github:mainfrom
mohitmishra786:3915-owner-repo-together

Conversation

@mohitmishra786

Copy link
Copy Markdown

Summary

Return an error when owner is given without repo (or the reverse) in list_notifications, mark_all_notifications_read, search_issues and search_pull_requests, instead of silently acting on all repositories.

Why

These tools only scope to a repository when both values are set. A lone owner was dropped, so mark_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

  • Add checkOwnerRepoPair in params.go and call it in the two notification handlers and in prepareSearchArgs.
  • Search tools still accept a lone owner/repo when the query already has a repo: qualifier, since the query filter is used then and those calls work today.
  • Tests: new owner-only and repo-only cases for both notification tools. The four existing search cases named "only owner/repo parameter (should ignore it)" now expect the error; this is the intended behavior change. Added a search case for owner plus a repo: qualifier.

MCP impact

  • No tool or API changes
  • Tool schema or behavior changed
    Schemas are unchanged. Calls with only one of owner/repo now return a tool error instead of running unscoped.
  • New tool added

Prompts tested (tool changes only)

  • "Mark all notifications in octocat as read" (model passes only owner): now returns an error instead of marking all notifications read.
  • "Search issues about bug in octocat's repos" with only owner: now returns an error instead of an unscoped search.

Security / limits

  • No security or limits impact
  • Auth / permissions considered
    Prevents a write from acting on a wider scope than the caller asked for.
  • Data exposure, filtering, or token/size limits considered

Tool renaming

  • I am renaming tools as part of this PR (e.g. a part of a consolidation effort)
    • I have added the new tool aliases in deprecated_tool_aliases.go
  • I am not renaming tools as part of this PR

Lint & tests

  • Linted locally with ./script/lint
  • Tested locally with ./script/test

The new cases fail on unmodified main and pass with this change.

Docs

  • Not needed
  • Updated (README / docs / examples)

script/generate-docs produces no changes; tool descriptions are unchanged.

Skills

  • Updated relevant skills or confirmed no bundled skill applies

notification-triage, issue-backlog-triage, issue-authoring and release-preparation already pass both owner and repo or a repo: qualifier, so no skill update is needed.

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
@mohitmishra786
mohitmishra786 requested a review from a team as a code owner November 21, 2026 15:56
Copilot AI adaptive review requested due to automatic review settings November 21, 2026 15:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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 owner and repo together.
  • 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) {
@vita122130

Copy link
Copy Markdown

Bnans

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.

Notification and search tools ignore owner when repo is missing and act on all repositories

3 participants