{"record":{"id":"344e85af6ef57dc6","repo":"can1357/oh-my-pi","slug":"all-failures-length-pr-checkouts-failed-fail","errorCode":null,"errorMessage":"all ${failures.length} PR checkouts failed:\n${failureLines.join(\"\\n\")}","messagePattern":"all (.+?) PR checkouts failed:\n(.+?)","errorType":"exception","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/gh-pr-checkout.ts","lineNumber":335,"sourceCode":"\n\tconst settled = await Promise.allSettled(\n\t\tprRefs.map(prRef => checkoutPullRequest(session, signal, { prRef, repo, force })),\n\t);\n\tconst outcomes: PrCheckoutOutcome[] = [];\n\tconst failures: Array<{ prRef: string | undefined; reason: unknown }> = [];\n\tfor (let i = 0; i < settled.length; i++) {\n\t\tconst entry = settled[i];\n\t\tif (entry.status === \"fulfilled\") outcomes.push(entry.value);\n\t\telse failures.push({ prRef: prRefs[i], reason: entry.reason });\n\t}\n\tif (failures.length > 0) {\n\t\tthrowIfAborted(signal);\n\t\tconst failureLines = failures.map(\n\t\t\tf => `- ${f.prRef ?? \"(current branch)\"}: ${f.reason instanceof Error ? f.reason.message : String(f.reason)}`,\n\t\t);\n\t\tif (outcomes.length === 0) {\n\t\t\tif (failures.length === 1) throw failures[0].reason;\n\t\t\tthrow new ToolError(`all ${failures.length} PR checkouts failed:\\n${failureLines.join(\"\\n\")}`);\n\t\t}\n\t\t// Partial success: report the worktrees that did get created alongside\n\t\t// the failures so the agent does not lose track of them.\n\t\tconst sections = outcomes.map(formatPrCheckoutResult);\n\t\tconst header = `# ${outcomes.length}/${settled.length} Pull Request Worktrees checked out (${failures.length} failed)`;\n\t\tconst text = [header, \"\", ...joinSections(sections), \"\", \"## Failed\", ...failureLines].join(\"\\n\").trim();\n\t\treturn buildTextResult(text, undefined, {\n\t\t\trepo,\n\t\t\tcheckouts: outcomes.map(outcomeToSummary),\n\t\t});\n\t}\n\n\tif (!isMulti) {\n\t\tconst [outcome] = outcomes;\n\t\treturn buildTextResult(formatPrCheckoutResult(outcome), outcome.data.url, {\n\t\t\trepo: repo ?? outcome.data.headRepository?.nameWithOwner,\n\t\t\tbranch: outcome.localBranch,\n\t\t\tworktreePath: outcome.worktreePath,","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/gh-pr-checkout.ts#L317-L353","documentation":"executePrCheckout can check out multiple PRs in one call. If every requested PR failed (outcomes empty) and there is more than one failure, it aggregates the per-PR reasons into one ToolError listing each failure line. For a single failure it rethrows the original error instead, so this multi-failure aggregate only appears for batch requests.","triggerScenarios":"Calling the pr_checkout op with several PR refs where all fail — e.g. all numbers are invalid/deleted PRs, all hit network/auth failures, or a mix of the per-PR errors (2430, 2435-2436) across every requested PR.","commonSituations":"Batching many PR numbers from an old list where PRs were closed/deleted; GitHub outage hitting all requests; invalid ref strings in every entry of the batch.","solutions":["Read the per-PR failure lines in the message; fix the specific cause for each (invalid identifier, missing clone URL, etc.) and retry only the failing PRs.","Retry with a single PR ref to get the underlying error directly instead of the aggregate.","Verify gh auth (`gh auth status`) and network connectivity if every PR failed with a similar message.","Drop PRs that no longer exist from the batch; use `gh pr view <N>` to check each one."],"exampleFix":"// before: op pr_checkout 101 102 103 → all failed aggregate\n// after: diagnose individually\ngh pr view 101 --json number\nop pr_checkout 101","handlingStrategy":"try-catch","validationCode":"for (const ref of prRefs) {\n  const ok = await gh.prView(ref).then(v => typeof v.number === \"number\").catch(() => false);\n  if (!ok) console.warn(`PR ${ref} unreachable — remove from batch`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await op.prCheckout({ prRefs: batch });\n} catch (err) {\n  if (err instanceof ToolError && err.message.startsWith(\"all \")) {\n    const perPr = err.message.split(\"\\n\").filter(l => l.startsWith(\"- \"));\n    for (const line of perPr) logFailure(line); // handle each PR individually\n  } else throw err;\n}","preventionTips":["Pre-check each PR with `gh pr view <N>` before batching.","Keep batch sizes small so one transient failure doesn't doom everything.","Verify gh auth/network before large batch runs.","Drop closed/deleted PRs from batch lists regularly."],"tags":["batch","pr-checkout","github-cli"],"backgroundTag":"batch-all-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}