can1357/oh-my-pi · error · ToolError
GitHub CLI returned an unrecognized repository URL: ${url}
Error message
GitHub CLI returned an unrecognized repository URL: ${url} What it means
resolveRepoFromCwd runs `gh repo view --json url -q .url` and parses the returned URL into an owner/name slug. If gh returns a URL that repoFromUrl cannot recognize, it throws this ToolError — meaning the GitHub CLI output is in an unexpected format (unusual host, enterprise remote, or gh misconfiguration).
Source
Thrown at packages/coding-agent/src/tools/gh-common.ts:226
const leftRef = parseRepoRef(left);
const rightRef = parseRepoRef(right);
if (effectiveHost(leftRef) !== effectiveHost(rightRef)) return false;
return leftRef.slug.toLowerCase() === rightRef.slug.toLowerCase();
}
/**
* Ask `gh` which repository the checkout points at, as `[HOST/]OWNER/REPO`.
*
* `nameWithOwner` alone would drop the host, and `gh` resolves a host-less
* `--repo` against `GH_HOST` (github.com by default) — so an enterprise
* checkout would silently be looked up on github.com. The repo URL carries
* the host `gh` itself resolved from the remote.
*/
async function resolveRepoFromCwd(cwd: string, signal?: AbortSignal): Promise<string> {
const url = requireNonEmpty(await github.text(cwd, ["repo", "view", "--json", "url", "-q", ".url"], signal), "repo");
const repo = repoFromUrl(url);
if (!repo) {
throw new ToolError(`GitHub CLI returned an unrecognized repository URL: ${url}`);
}
return repo;
}
export async function resolveGitHubRepo(
cwd: string,
repo: string | undefined,
runRepo: string | undefined,
signal?: AbortSignal,
): Promise<string> {
if (repo && runRepo && !githubRepoSlugEquals(repo, runRepo)) {
throw new ToolError("run URL repository does not match the provided repo");
}
if (repo) {
return repo;
}
View on GitHub (pinned to 9690622007)
Solutions
- Pass the repo explicitly (owner/name) instead of relying on cwd resolution.
- Check `gh repo view --json url` output and `gh auth status`; fix the host with `gh auth login` for the right hostname.
- Update (or pin) the gh CLI to a version producing standard https://host/owner/repo URLs.
- Ensure the git remote origin points at a standard GitHub URL.
Example fix
// before (relies on cwd resolution) const repo = await resolveGitHubRepo(cwd); // after const repo = await resolveGitHubRepo(cwd, "owner/name");
Defensive patterns
Strategy: try-catch
Validate before calling
import { $ } from "bun";
const res = await $`gh repo view --json url -q .url`.cwd(cwd).quiet().nothrow();
const url = res.exitCode === 0 ? res.text().trim() : "";
const ok = /^https:\/\/[^/]+\/[^/]+\/[^/]+$/.test(url);
if (!ok) repo = "owner/name"; // pass explicitly Try / catch
try {
repo = await resolveGitHubRepo(cwd);
} catch (err) {
if (err instanceof ToolError && err.message.includes("unrecognized repository URL")) {
repo = configuredDefaultRepo; // e.g. from config/env
} else throw err;
} Prevention
- Pin/update the gh CLI and keep `gh auth status` valid for the right host.
- Pass repo explicitly (owner/name) whenever the environment is not a standard github.com clone.
- For GitHub Enterprise, confirm the host is recognized by gh (hosts.yml).
When it happens
Trigger: `gh repo view` succeeds in cwd but emits a URL that does not match expected github.com (or accepted host) patterns — e.g. a non-GitHub remote behind an enterprise proxy, a rewritten gh host alias, or a gh version producing a different URL shape.
Common situations: GitHub Enterprise with custom hostname not in gh's recognized hosts; gh authenticated against a different host; malformed git remote causing gh to echo an odd URL; older/newer gh CLI output format changes.
Related errors
- Invalid URL encoding in vault:// path: ${url.href}
- run URL repository does not match the provided repo
- Replacement text is not valid UTF-8: {err}
- V2 compaction stream parse failed: ${err instanceof Error ?
- ${source} response is missing credentials.
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/2fefca9501151a8e.
Report an issue: GitHub.