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.
Evidence#
Create a synthetic GitHub project and replay-agent thread on fresh isolated server state. Call
link_pull_requestover authenticated MCP withrepository: "github.com/org/repo"andnumber: 123, letting the project supply the host. These are real server runtime transcripts.Both calls returned
isError: true.Reproduction and seed driver
Not shown: