Skip to content

Reject unsupported pagination params in pull_request_read - #3336

Open
muhammadumer-waheed wants to merge 1 commit into
github:mainfrom
muhammadumer-waheed:fix/pr-read-pagination-param-validation
Open

muhammadumer-waheed wants to merge 1 commit into
github:mainfrom
muhammadumer-waheed:fix/pr-read-pagination-param-validation

Conversation

@muhammadumer-waheed

Copy link
Copy Markdown

Summary

pull_request_read now returns a validation error when a pagination parameter is passed that the selected method does not use, instead of silently dropping it.

Why

A pagination parameter that the selected method cannot honour was silently dropped: an agent following the schema and passing after to e.g. get_files would get the first page back again with no signal that anything was ignored. Silent parameter drops are worst-case for agentic callers, since the tool reports success with a plausible payload and the model has no reason to retry.

Fixes #3316

What changed

  • Added validatePaginationParamsForMethod in pkg/github/pullrequests.go, called before the tool dispatches on method:
    • after is rejected for all methods except get_review_comments (with a hint to use get_review_comments for cursor-based pagination)
    • page is rejected for get_review_comments, which uses cursor-based pagination
    • perPage remains accepted for every method
  • Added table-driven tests covering both rejection cases plus positive cases confirming page/perPage still work for get_files and perPage/after still work for get_review_comments.

MCP impact

  • No tool or API changes
  • Tool schema or behavior changed
  • New tool added

The pull_request_read input schema is unchanged; behavior only: passing a pagination parameter the selected method does not honour now returns an error naming the method and the parameter, instead of silently returning the first page.

Prompts tested (tool changes only)

  • "Show me the files changed in PR [docker] build arm64 #42, page 2 with 10 per page" → get_files with page/perPage: accepted (covered by unit test)
  • "Get the review comments on PR [docker] build arm64 #42 after cursor cursor-page-2" → get_review_comments with after: accepted (covered by unit test)
  • "Get the files changed in PR [docker] build arm64 #42 after cursor cursor-page-2" → get_files with after: now errors with method "get_files" uses page/perPage pagination; "after" is not supported (covered by unit test)

Security / limits

  • No security or limits impact
  • Auth / permissions considered
  • 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

Docs

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

The pull_request_read tool exposes two pagination mechanisms:
page/perPage for the REST-backed methods and the after cursor for
get_review_comments. Passing a parameter the selected method does not
use was silently dropped, so callers (especially LLM agents) would
receive the first page again with no signal that anything was ignored.

Validate the pagination parameters against the selected method before
dispatch and return a tool error naming the method and the parameter:

- after is rejected for all methods except get_review_comments
- page is rejected for get_review_comments
- perPage remains accepted for every method

Fixes github#3316
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.

pull_request_read silently ignores pagination parameters that don't apply to the selected method

1 participant