{"record":{"id":"8ac0dfb67ee203e7","repo":"can1357/oh-my-pi","slug":"pr-parsed-number-could-not-resolve-a-default","errorCode":null,"errorMessage":"pr://${parsed.number} could not resolve a default repo from the current session: ${message}\nUse pr://<owner>/<repo>/${parsed.number}.","messagePattern":"pr://(.+?) could not resolve a default repo from the current session: (.+?)\nUse pr://<owner>/<repo>/(.+?)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/internal-urls/issue-pr-protocol.ts","lineNumber":593,"sourceCode":"\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,\n\t\t\t\tnumber: parsed.number,\n\t\t\t\tincludeComments: parsed.comments,\n\t\t\t\tsignal: context?.signal,\n\t\t\t\tsettings: settingsFromContext(context),\n\t\t\t});\n\t\t\treturn buildSingleResource({\n\t\t\t\turl,\n\t\t\t\tscheme: \"pr\",\n\t\t\t\tparsed,\n\t\t\t\trendered: lookup.rendered,","sourceCodeStart":575,"sourceCodeEnd":611,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/internal-urls/issue-pr-protocol.ts#L575-L611","documentation":"Thrown by PrProtocolHandler.resolve (packages/coding-agent/src/internal-urls/issue-pr-protocol.ts:593) when a repo-less pr://<n> URL is used and resolveDefaultRepoMemoized cannot infer the owner/repo from the current session (git remotes, gh config). The message instructs the user to disambiguate with pr://<owner>/<repo>/<n>. This is an actionable configuration/environment error, not a bug.","triggerScenarios":"Resolving pr://<n> (no repo segment) when the cwd is not a git repository, the git remote is not a GitHub remote (or absent), or repo detection fails for any other reason (detached/dirty remotes, multiple remotes without origin, SSH remote parsing failure).","commonSituations":"Running the agent outside a repo or in a bare directory; project hosted on GitLab/Bitbucket so no GitHub remote exists; multiple remotes and no clear default; remote URL in an unrecognized format.","solutions":["Use the fully-qualified URL form: pr://<owner>/<repo>/<n> — this bypasses default-repo detection entirely.","cd into the project's git checkout (or pass a ResolveContext whose cwd is inside it) so a GitHub remote can be detected.","Ensure the repo has a GitHub remote: `git remote -v`; add one with `git remote add origin git@github.com:owner/repo.git` if missing.","Run `gh repo set-default owner/repo` so gh-based default resolution has an unambiguous answer.","Read the inner message after the colon — it carries the underlying detection failure."],"exampleFix":"// before\nconst res = await prHandler.resolve(parse(\"pr://1234\")); // relies on cwd detection\n// after\nconst res = await prHandler.resolve(parse(\"pr://acme/widgets/1234\")); // explicit repo","handlingStrategy":"validation","validationCode":"// Verify a default repo is derivable before using the repo-less form:\nconst remotes = await $`git remote -v`.cwd(process.cwd()).quiet().nothrow();\nconst hasGithubRemote = /github\\.com[/:][\\w.-]+\\/[\\w.-]+/.test(remotes.text() ?? \"\");\nif (!hasGithubRemote) throw new Error(\"No GitHub remote; use explicit pr://owner/repo/<n>\");","typeGuard":"null","tryCatchPattern":"try {\n  return await prHandler.resolve(parse(`pr://${n}`), ctx);\n} catch (err) {\n  if (err instanceof Error && err.message.includes(\"could not resolve a default repo\")) {\n    logger.warn(\"default repo unresolved; ask user for owner/repo\");\n    return promptForRepoThenResolve(n);\n  }\n  throw err;\n}","preventionTips":["Always construct pr:// URLs with an explicit owner/repo segment.","Run the agent inside the project's git checkout so remotes are detectable.","Set a gh default repo (`gh repo set-default owner/repo`) for unambiguous resolution.","Ensure the repo has a GitHub remote; non-GitHub hosts cannot be auto-resolved.","Handle the embedded 'Use pr://<owner>/<repo>/<n>' hint by falling back to the qualified form automatically."],"tags":["git","configuration","repo-resolution","github","protocol-handler"],"backgroundTag":"default-repo-not-resolved","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}