Skip to content
Source
Sign inSign up
pingdotgg/t3code

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

Mergediamshadmantaqi(GitHub profile, opens in a new tab)merged 4 commits intomain fromrefs/pull/41397/headmerged by juliusmarminge View on GitHub

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.

    1. Pushed6ecc18c

    2. 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.

      BeforeAfter
      1e088be4b56ecc18c330
      “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 captureAfter 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.
    3. juliusmarminge added labelstakeover:ready

    4. juliusmarminge removed labelstakeover:in-progress

    5. juliusmarminge merged this5b643a4

    6. juliusmarminge closed this

    7. juliusmarminge removed labelstakeover:ready

Sign in to join this conversation.