{"record":{"id":"e825f444ed1ad874","repo":"denoland/deno","slug":"failed-to-find-pr-pr-number-stderr","errorCode":null,"errorMessage":"Failed to find PR #{pr_number}: {stderr}","messagePattern":"Failed to find PR #(.+?): (.+?)","errorType":"exception","errorClass":"AnyError","httpStatus":null,"severity":"error","filePath":"cli/tools/upgrade.rs","lineNumber":642,"sourceCode":"  // Verify the PR exists and get its title/state/branch\n  let pr_info = Command::new(\"gh\")\n    .args([\n      \"pr\",\n      \"view\",\n      &pr_number.to_string(),\n      \"--repo\",\n      \"denoland/deno\",\n      \"--json\",\n      \"title,state,headRefName,headRefOid\",\n      \"-q\",\n      r#\"[.title, .state, .headRefName, .headRefOid] | @tsv\"#,\n    ])\n    .output()\n    .context(\"failed to run `gh pr view`\")?;\n\n  if !pr_info.status.success() {\n    let stderr = String::from_utf8_lossy(&pr_info.stderr);\n    bail!(\"Failed to find PR #{pr_number}: {stderr}\");\n  }\n\n  let pr_info_str = String::from_utf8_lossy(&pr_info.stdout);\n  let pr_fields: Vec<&str> = pr_info_str.trim().splitn(4, '\\t').collect();\n  let pr_title = pr_fields.first().unwrap_or(&\"unknown\");\n  let pr_state = pr_fields.get(1).unwrap_or(&\"unknown\");\n  let pr_branch = pr_fields.get(2).unwrap_or(&\"\");\n  let pr_head_sha = pr_fields.get(3).unwrap_or(&\"\");\n\n  log::info!(\n    \"PR #{}: {} ({})\",\n    pr_number,\n    colors::bold(pr_title),\n    pr_state\n  );\n\n  let artifact_name = get_pr_artifact_name()?;\n  let debug_artifact_name = get_pr_debug_artifact_name()?;","sourceCodeStart":624,"sourceCodeEnd":660,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/upgrade.rs#L624-L660","documentation":"After confirming gh exists, Deno runs `gh pr view <n> --repo denoland/deno --json ...` to fetch the PR's title, state, branch, and head SHA. If gh exits non-zero, Deno bails with 'Failed to find PR' plus gh's stderr. The stderr text is the real diagnosis: unknown PR number, no authentication, no network, or permission problems.","triggerScenarios":"`deno upgrade --pr <n>` where the PR number does not exist in denoland/deno; gh has no valid token (`gh auth login` not run or expired); GitHub is unreachable; the `gh pr view` invocation itself fails (bad gh version missing --json/-q support).","commonSituations":"Typos in the PR number; referencing an issue number instead of a PR number; CI/container environments where gh is installed but unauthenticated; corporate proxies blocking api.github.com.","solutions":["Run `gh pr view <n> --repo denoland/deno` yourself and read the stderr Deno printed — it states the exact cause.","Fix authentication: `gh auth login` (or `gh auth status` to inspect the current token).","Confirm the number is a real PR (not an issue) in denoland/deno and retry with the correct ID.","If it is a network/proxy problem, fix connectivity to github.com/api.github.com and retry."],"exampleFix":"# before\ndeno upgrade --pr 1234  # typo, PR does not exist\n\n# after\ndeno upgrade --pr 12345  # verify via: gh pr view 12345 --repo denoland/deno","handlingStrategy":"try-catch","validationCode":"gh pr view 12345 --repo denoland/deno --json state >/dev/null 2>&1 || { echo \"PR missing or gh not authed\"; exit 1; }\ndeno upgrade --pr 12345","typeGuard":null,"tryCatchPattern":"if ! deno upgrade --pr 12345 2>err.log; then grep -q 'Failed to find PR' err.log && cat err.log; fi","preventionTips":["Validate the PR number with `gh pr view` before invoking the upgrade.","Keep gh authenticated (`gh auth status`) in automation.","Distinguish PR numbers from issue numbers when copying IDs."],"tags":["upgrade","gh-cli","pr-build","not-found","authentication"],"backgroundTag":"pr-not-found","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}