Skip to content

fix(server): pull request tools say when repository is not owner/repo - #41397

Merged
juliusmarminge merged 4 commits into
pingdotgg:mainfrom
iamshadmantaqi:fix/pr-target-repository-format
Nov 23, 2026
Merged

juliusmarminge merged 4 commits into
pingdotgg:mainfrom
iamshadmantaqi:fix/pr-target-repository-format

Conversation

@iamshadmantaqi

Copy link
Copy Markdown
Contributor

Problem

On a GitHub project, link_pull_request({ repository: "github.com/org/repo", number: 1 }) fails with PullRequestUrlUnavailableError: "This thread's project is on a host with no known pull request URL shape. Pass url." The host is known. The real problem is the repository value: GitHub's changeRequestUrl returns null when repository is not a strict owner/repo (isRepositoryPath in packages/source-control-github/src/shared/definition.ts), and resolveTarget reads every null URL as an unknown host. The agent is told to fix the wrong thing.

Change

resolveTarget in apps/server/src/pullRequest/pullRequestTarget.ts now looks at which definition produced the null URL. With no provider kind, or the unknown definition, it still returns PullRequestUrlUnavailableError. With a known forge, it returns a new PullRequestRepositoryInvalidError: "Pass repository as owner/repo, without the host. Or pass url, or leave out repository."

The new error follows the existing target errors (empty tagged error with a message getter), joins PullRequestTargetError, and is registered in the import and the PullRequestToolError union in apps/server/src/mcp/toolkits/pullRequests/tools.ts. No client or contracts schema lists these errors.

Scope

Fixes #41385

Only the error chosen when a known forge cannot build the URL changes. Valid input resolves exactly as before, and an unknown host still gets the old error.

Verification

Added one case to apps/server/src/mcp/toolkits/pullRequests/handlers.test.ts, next to the unknown host case. It calls link_pull_request on the default GitHub project with repository: "github.com/org/repo" and checks the error tag, that the message mentions owner/repo, and that no link command was dispatched.

Without the fix (test commit only):

 FAIL  src/mcp/toolkits/pullRequests/handlers.test.ts > pull request toolkit handlers > says when repository is not owner/repo on a known host
AssertionError: expected PullRequestUrlUnavailableError: This thre… { _tag: '…' } to match object { Object (_tag) }

- Expected
+ Received

- {
-   "_tag": "PullRequestRepositoryInvalidError",
+ PullRequestUrlUnavailableError {
+   "_tag": "PullRequestUrlUnavailableError",
  }

With the fix:

$ vp test run src/mcp/toolkits/pullRequests/handlers.test.ts
 Test Files  1 passed (1)
      Tests  34 passed (34)

vp test run src/mcp/toolkits/pullRequests/handlers.test.ts src/pullRequest also passes (9 files, 213 tests).

vp run check:changed: format, lint, knip, graphql, typecheck (3 packages) and tests (2 files) all pass.

Not verified: I did not run the evals/ cases for model-facing text or try the tool from a live agent session; the change is covered by the handler test only.

Model: Claude Opus 5.5. Harness: Claude Code in T3 Code.

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 23, 2026
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Target resolution now reports invalid repository values separately from unavailable pull request URL shapes. The MCP tool error union includes the new error, and a test covers a host-prefixed repository value.

Changes: Repository validation

Layer / File(s) Summary
Target error classification
apps/server/src/pullRequest/pullRequestTarget.ts
Adds PullRequestRepositoryInvalidError with repository format guidance. When URL generation fails for a known host, resolveTarget returns this error; absent or unknown host definitions still return PullRequestUrlUnavailableError.
MCP error reporting and validation
apps/server/src/mcp/toolkits/pullRequests/tools.ts, apps/server/src/mcp/toolkits/pullRequests/handlers.test.ts
Adds the new error to PullRequestToolError. A test verifies that a host-prefixed repository value produces this error and dispatches no command.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related issues

  • #41396 — The new error gives format guidance for rejected repository values. Prefix stripping and schema descriptions are not covered.
  • #41394 — The change handles invalid repository input on known forges. The unavailable-URL error path for unknown forges remains unchanged.

Suggested labels: bugfix

Suggested reviewers: juliusmarminge, macroscopeapp

Merge Risk: Minimal · up to 6ecc1

The PR gives a clearer error when a repository value such as a host-prefixed one is passed for a known forge. No concrete merge risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix and the affected area: pull request tools now report when the repository value is not owner/repo. It matches the main change, which adds PullRequestRepositoryInvalidError for a…
Description check Passed The description follows the template sections (Problem, Change, Scope, Verification) and fills each one with specific content. It explains the root cause in resolveTarget, the new error and its wiring…
Linked Issues check Passed [#41385] asks that resolveTarget separate an unknown forge from a known forge whose URL builder rejects repository. The whole-PR diff (merge base to head) in apps/server/src/pullRequest/pullRequestTar…
Out of Scope Changes check Passed The whole-PR diff of pullRequestTarget.ts only adds the new error class, adds it to the PullRequestTargetError union, and changes the null-URL branch in resolveTarget. These changes implement #41385. …
Full details: Title check

Explanation

The title names the fix and the affected area: pull request tools now report when the repository value is not owner/repo. It matches the main change, which adds PullRequestRepositoryInvalidError for a known forge whose URL builder rejects the repository. The title is concise and specific.

Full details: Description check

Explanation

The description follows the template sections (Problem, Change, Scope, Verification) and fills each one with specific content. It explains the root cause in resolveTarget, the new error and its wiring, links issue #41385, and reports the failing-then-passing handler test with commands and results. It also states what was not verified, including evals/ and a live agent session. The template's optional model/harness line is present. The template's screenshot requirement applies only to UI changes, which this PR does not contain.

Full details: Linked Issues check

Explanation

[#41385] asks that resolveTarget separate an unknown forge from a known forge whose URL builder rejects repository. The whole-PR diff (merge base to head) in apps/server/src/pullRequest/pullRequestTarget.ts resolves the definition first. If kind is null or definition.kind is "unknown", the code returns PullRequestUrlUnavailableError. If a known definition returns a null URL, the code returns the new PullRequestRepositoryInvalidError. The issue accepts either a clear owner/repo validation error or normalization for known GitHub hosts. This PR uses the validation error. The new error message is "Pass repository as owner/repo, without the host." This message states the required format. Because the change is in resolveTarget, it applies to every tool that uses it, including pull_request_respond and link_pull_request. Valid inputs follow the same path as before. The handler test is described in the PR, but I did not read its contents at head. The incremental diff from the previous reviewed head could not be read, so I assessed the change from the whole-PR diff. Note: the PR description quotes a longer message that also mentions pass url or omitting repository. The code message is shorter. This difference does not affect the issue requirement.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff of pullRequestTarget.ts only adds the new error class, adds it to the PullRequestTargetError union, and changes the null-URL branch in resolveTarget. These changes implement #41385. The PR description reports that tools.ts registers the new error in the PullRequestToolError union, and that handlers.test.ts adds one case for the new behavior. Those changes support the new error and do not add unrelated behavior. The PR does not change client or contracts schemas, as described. I did not read the tools.ts or handlers.test.ts diffs, so this verdict relies on the PR summary for those files. The incremental diff since the previous reviewed head could not be read. No unrelated change was found in the evidence available.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between c58f651 and 6ecc18c.

Files selected for processing: 1

  • apps/server/src/pullRequest/pullRequestTarget.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 23, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Create a synthetic GitHub project and replay-agent thread on fresh isolated server state. Call link_pull_request over authenticated MCP with repository: "github.com/org/repo" and number: 123, letting the project supply the host. These are real server runtime transcripts.

Before After
1e088be4b5 6ecc18c330
“This thread's project is on a host with no known pull request URL shape. Pass url.” “Pass repository as owner/repo, without the host.”
Before runtime capture After runtime capture

Both calls returned isError: true.

Reproduction and seed driver

Not shown:

  • GitHub Enterprise and other pull request tools were not exercised; runtime proof covers link_pull_request on a recognized public GitHub project.
  • The call was driven directly through the real MCP endpoint rather than by a model choosing the tool in the web client.
  • MCP exposes the error message, not its internal tagged class; the runtime captures prove the guidance change.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Nov 23, 2026
@juliusmarminge
juliusmarminge merged commit 5b643a4 into pingdotgg:main Nov 23, 2026
54 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Nov 23, 2026
juliusmarminge added a commit that referenced this pull request Nov 23, 2026
main fixed the same bug in #41397; take main's resolveTarget and test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
juliusmarminge added a commit that referenced this pull request Nov 23, 2026
…d of stripping the host

#41397 on main rejects host-prefixed repositories with a clear error, so
the host stripping and its test are dropped; the schema descriptions stay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: resolveTarget misreports an invalid or host-prefixed repository as an unknown host ("no known pull request URL shape")

2 participants