stablyai/orca · error
Invalid pull request number: ${String(prNumber)}
Error message
Invalid pull request number: ${String(prNumber)} What it means
Thrown by fetchGitHubPullRequestHeadRef when isValidReviewHeadNumber rejects prNumber. The guard exists because prNumber is interpolated into a refspec (`+refs/pull/<n>/head:...`) and passed as a CLI argument; a malformed value could produce an invalid refspec or, worse, an argv-style token. Typical valid values are positive integers; anything else (0, negative, NaN, fractional, non-numeric) is refused.
Source
Thrown at src/main/github/pr-head-tracking-ref.ts:47
options.localGitExecOptions ?? { cwd: repo.path }
)
return
}
if (!sshGitProvider) {
throw new Error('SSH Git provider is not available. Reconnect to this target and try again.')
}
await sshGitProvider.fetchRemoteTrackingRef(repo.path, remote, branch, ref)
}
export async function fetchGitHubPullRequestHeadRef(
repo: { path: string; connectionId?: string | null },
sshGitProvider: SshGitProvider | null | undefined,
remote: string,
prNumber: number,
options: { localGitExecOptions?: LocalGitExecOptions } = {}
): Promise<string> {
if (!isValidReviewHeadNumber(prNumber)) {
throw new Error(`Invalid pull request number: ${String(prNumber)}`)
}
if (!isSafeReviewHeadFetchRemote(remote)) {
throw new Error('Pull request fetch remote must not start with "-".')
}
if (!repo.connectionId) {
const localGitExecOptions = options.localGitExecOptions ?? { cwd: repo.path }
const remoteComponent = await getReviewHeadRemoteComponent(remote, localGitExecOptions)
// Why: return the same path the fetch wrote so callers don't re-resolve identity.
const localRef = githubPullRequestHeadLocalRef(remoteComponent, prNumber)
await gitExecFileAsync(
['fetch', '--no-tags', remote, `+refs/pull/${prNumber}/head:${localRef}`],
{
...localGitExecOptions,
timeout: REVIEW_HEAD_FETCH_TIMEOUT_MS
}
)
return localRef
}View on GitHub (pinned to 1136503c6a)
Solutions
- Validate prNumber is a positive integer at the call site before invoking fetchGitHubPullRequestHeadRef.
- If the value comes from a URL or user input, parse with Number and guard with Number.isSafeInteger && n > 0.
- Discard placeholder/sentinel values (0, -1) at the UI layer.
Example fix
// before
await fetchGitHubPullRequestHeadRef(repo, provider, remote, rawNumber)
// after
if (!Number.isSafeInteger(rawNumber) || rawNumber <= 0) {
toast.error('Invalid PR number.')
return
}
await fetchGitHubPullRequestHeadRef(repo, provider, remote, rawNumber) Defensive patterns
Strategy: validation
Validate before calling
function isValidPrNumber(n: unknown): n is number {
return typeof n === 'number' && Number.isSafeInteger(n) && n > 0
} Type guard
function isValidPrNumber(n: unknown): n is number {
return typeof n === 'number' && Number.isSafeInteger(n) && n > 0
} Try / catch
if (!isValidPrNumber(prNumber)) {
toast.error('Invalid PR number.')
return
}
await fetchGitHubPullRequestHeadRef(repo, provider, remote, prNumber) Prevention
- Parse PR numbers from URLs with Number() and guard with Number.isSafeInteger && n > 0.
- Discard UI placeholder values (0, -1, NaN) before they reach the fetch.
- Validate at the deep-link / extension API boundary, not at the git call site.
When it happens
Trigger: Caller passes 0, a negative number, NaN, undefined (coerced to 'undefined'), a fractional PR number, or a value parsed from a malformed URL/deep link; a UI bug sending a placeholder sentinel before the real PR loads.
Common situations: Deep-link handler routing `/pull/abc` into the fetch; UI placeholder 0 reaching the call before the PR resolves; serialized action with corrupted PR number.
Related errors
- Pull request fetch remote must not start with "-".
- repo is required
- token is required
- GITHUB_REPOSITORY must be in owner/repo form, got "${options
- Invalid branch name
AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12).
Data as JSON: /api/errors/9919a205567e6f3c.
Report an issue: GitHub.