can1357/oh-my-pi · error
pr://${parsed.number} could not resolve a default repo from
Error message
pr://${parsed.number} could not resolve a default repo from the current session: ${message}
Use pr://<owner>/<repo>/${parsed.number}. What it means
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.
Source
Thrown at packages/coding-agent/src/internal-urls/issue-pr-protocol.ts:593
throw new Error(`pr:// listing failed: ${message}`);
}
}
if (parsed.kind === "pr-diff") {
try {
return await fetchAndRenderPrDiff(url, parsed, context);
} catch (err) {
const message = err instanceof Error ? err.message : String(err);
throw new Error(`pr:// diff resolution failed: ${message}`);
}
}
const cwd = resolveCwd(context);
let repo = parsed.repo;
if (!repo) {
try {
repo = await resolveDefaultRepoMemoized(cwd, context?.signal);
} catch (err) {
const message = err instanceof Error ? err.message : String(err);
throw new Error(
`pr://${parsed.number} could not resolve a default repo from the current session: ${message}\nUse pr://<owner>/<repo>/${parsed.number}.`,
);
}
}
try {
const lookup = await getOrFetchPr({
cwd,
repo,
number: parsed.number,
includeComments: parsed.comments,
signal: context?.signal,
settings: settingsFromContext(context),
});
return buildSingleResource({
url,
scheme: "pr",
parsed,
rendered: lookup.rendered,View on GitHub (pinned to 9690622007)
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.
Example fix
// before
const res = await prHandler.resolve(parse("pr://1234")); // relies on cwd detection
// after
const res = await prHandler.resolve(parse("pr://acme/widgets/1234")); // explicit repo Defensive patterns
Strategy: validation
Validate before calling
// Verify a default repo is derivable before using the repo-less form:
const remotes = await $`git remote -v`.cwd(process.cwd()).quiet().nothrow();
const hasGithubRemote = /github\.com[/:][\w.-]+\/[\w.-]+/.test(remotes.text() ?? "");
if (!hasGithubRemote) throw new Error("No GitHub remote; use explicit pr://owner/repo/<n>"); Type guard
null
Try / catch
try {
return await prHandler.resolve(parse(`pr://${n}`), ctx);
} catch (err) {
if (err instanceof Error && err.message.includes("could not resolve a default repo")) {
logger.warn("default repo unresolved; ask user for owner/repo");
return promptForRepoThenResolve(n);
}
throw err;
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- origin remote is unavailable for this repository.
- issue:// listing failed: ${message}
- issue:// resolution failed: ${message}
- pr:// listing failed: ${message}
- pr:// diff resolution failed: ${message}
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/8ac0dfb67ee203e7.
Report an issue: GitHub.