{"record":{"id":"a162d3a8102916e5","repo":"can1357/oh-my-pi","slug":"pr-diff-resolution-failed-message","errorCode":null,"errorMessage":"pr:// diff resolution failed: ${message}","messagePattern":"pr:// diff resolution failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/internal-urls/issue-pr-protocol.ts","lineNumber":583,"sourceCode":"\tasync resolve(url: InternalUrl, context?: ResolveContext): Promise<InternalResource> {\n\t\tif (context?.signal?.aborted) {\n\t\t\tthrow new Error(\"aborted\");\n\t\t}\n\t\tconst parsed = parseUrl(url, \"pr\");\n\t\tif (parsed.kind === \"list\") {\n\t\t\ttry {\n\t\t\t\treturn await fetchAndRenderList(\"pr\", parsed, url, context);\n\t\t\t} catch (err) {\n\t\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\t\tthrow new Error(`pr:// listing failed: ${message}`);\n\t\t\t}\n\t\t}\n\t\tif (parsed.kind === \"pr-diff\") {\n\t\t\ttry {\n\t\t\t\treturn await fetchAndRenderPrDiff(url, parsed, context);\n\t\t\t} catch (err) {\n\t\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\t\tthrow new Error(`pr:// diff resolution failed: ${message}`);\n\t\t\t}\n\t\t}\n\t\tconst cwd = resolveCwd(context);\n\t\tlet repo = parsed.repo;\n\t\tif (!repo) {\n\t\t\ttry {\n\t\t\t\trepo = await resolveDefaultRepoMemoized(cwd, context?.signal);\n\t\t\t} catch (err) {\n\t\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`pr://${parsed.number} could not resolve a default repo from the current session: ${message}\\nUse pr://<owner>/<repo>/${parsed.number}.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tconst lookup = await getOrFetchPr({\n\t\t\t\tcwd,\n\t\t\t\trepo,","sourceCodeStart":565,"sourceCodeEnd":601,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/internal-urls/issue-pr-protocol.ts#L565-L601","documentation":"Wrapper error thrown by PrProtocolHandler.resolve (packages/coding-agent/src/internal-urls/issue-pr-protocol.ts:583) around fetchAndRenderPrDiff for pr://.../diff URLs (full diff, per-file slice, or file listing). Any failure inside that helper — default-repo resolution, getOrFetchPrDiff, range errors, internal parser assertions — is re-thrown with the `pr:// diff resolution failed: ${message}` prefix, preserving the cause's message.","triggerScenarios":"Resolving pr://owner/repo/<n>/diff, /diff/all, or /diff/<i> when the PR diff cannot be fetched or rendered: PR number nonexistent, huge diff fetch failure, gh/network errors, index out of range (a nested out-of-range error), or a parser-bug assertion (error 1530).","commonSituations":"Wrong PR number; PR in a private repo without auth; offline; GitHub API failure; asking for diff/<i> with an i beyond the file count; corrupted or stale cached diff payload.","solutions":["Read the inner message after `pr:// diff resolution failed: ` — out-of-range errors tell you the valid file count; use pr://owner/repo/<n>/diff to list indices.","Verify the PR exists: `gh pr view <n> -R owner/repo`.","Authenticate with `gh auth login` if the cause indicates auth/permission failure.","Retry after backoff for transient network/rate-limit causes.","Clear the cached diff for the PR if the payload appears stale or corrupt, then re-resolve."],"exampleFix":"// before\nconst res = await prHandler.resolve(parse(\"pr://acme/widgets/12/diff/3\"));\n// after\ntry {\n  const res = await prHandler.resolve(parse(\"pr://acme/widgets/12/diff/3\"));\n} catch (err) {\n  const cause = String(err.message).replace(\"pr:// diff resolution failed: \", \"\");\n  if (/out of range/.test(cause)) {\n    const listing = await prHandler.resolve(parse(\"pr://acme/widgets/12/diff\"));\n  } else throw err;\n}","handlingStrategy":"try-catch","validationCode":"// Fetch the file listing first and bound your slice index:\nconst listing = await prHandler.resolve(parse(`pr://${repo}/${n}/diff`));\nconst m = listing.content.match(/\\((\\d+) files?\\)/);\nconst count = Number(m?.[1] ?? 0);\nif (!(i >= 1 && i <= count)) throw new RangeError(`diff/${i} out of range (1..${count})`);","typeGuard":"function isPrDiffFailure(err: unknown): err is Error {\n  return err instanceof Error && err.message.startsWith(\"pr:// diff resolution failed: \");\n}","tryCatchPattern":"try {\n  return await prHandler.resolve(parse(`pr://${repo}/${n}/diff/${i}`), ctx);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"pr:// diff resolution failed: \")) {\n    if (/out of range/.test(err.message)) {\n      return await prHandler.resolve(parse(`pr://${repo}/${n}/diff`), ctx); // fall back to listing\n    }\n    throw err;\n  }\n  throw err;\n}","preventionTips":["Resolve the diff listing first; only request slices within the reported count.","Authenticate gh and confirm repo access before fetching diffs.","Handle the nested out-of-range message explicitly — it embeds the valid file count.","Retry transient network/rate-limit causes with backoff; clear corrupt cache entries."],"tags":["github","network","error-wrapping","diff","protocol-handler"],"backgroundTag":"github-fetch-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}