can1357/oh-my-pi · error · HTTPException
remote url does not match repo {expected_repo!r}
Error message
remote url does not match repo {expected_repo!r} What it means
Raised when the origin URL points at github.com but its repository path does not match the expected repo for the request (compared case-insensitively after stripping .git). This is a safety check: the proxy refuses to operate on a worktree whose origin belongs to a different repo than the one the client claims, preventing cross-repo operations.
Source
Thrown at python/robomp/src/proxy/server.py:335
if (parsed.scheme or "").lower() != "https":
raise HTTPException(400, f"remote url must be https://github.com/{expected_repo}[.git]")
if parsed.username or parsed.password:
raise HTTPException(400, "remote url must not contain embedded credentials")
try:
port = parsed.port
except ValueError as exc:
raise HTTPException(400, "remote url has invalid port") from exc
if port is not None:
raise HTTPException(400, "remote url must not specify a port")
if (parsed.hostname or "").lower() != "github.com":
raise HTTPException(400, f"remote url host must be github.com for repo {expected_repo!r}")
if parsed.params or parsed.query or parsed.fragment:
raise HTTPException(400, "remote url must not contain params, query, or fragment")
path = parsed.path.strip("/")
if path.endswith(".git"):
path = path[:-4]
if path.lower() != expected_repo.lower():
raise HTTPException(400, f"remote url does not match repo {expected_repo!r}")
return _github_url_for_repo(expected_repo)
def _remote_auth_for_url(url: str, expected_repo: str, token: str) -> _RemoteAuth:
raw = url.strip()
if not raw or raw != url:
raise HTTPException(400, "remote url must not be empty or padded")
if _FORBIDDEN_URL_BYTES_RE.search(raw):
raise HTTPException(400, "remote url contains forbidden control bytes")
if raw.startswith("-"):
raise HTTPException(400, "remote url must not start with '-'")
if _REMOTE_HELPER_RE.match(raw):
raise HTTPException(400, "git remote helper transports are disabled")
scheme = (urlparse(raw).scheme or "").lower()
if scheme in ("http", "https"):
normalized = _normalized_github_https_url(raw, expected_repo)
return _RemoteAuth(url=normalized, token=token, auth_url=normalized)
return _RemoteAuth(url=raw, token=None, auth_url=None)View on GitHub (pinned to 9690622007)
Solutions
- Verify which repo the worktree actually tracks: `git -C <dir> remote get-url origin`
- If the worktree is for the wrong repo, clone/point a worktree of the correct repo: `git remote set-url origin https://github.com/<expected_repo>.git`
- If the request's expected_repo is wrong, fix the client/proxy request payload to name the repo the worktree tracks
- If the repo was renamed on GitHub, update the remote to the new slug
Example fix
// before: worktree points at a fork but request targets acme/repo $ git remote get-url origin # https://github.com/acme/repo-fork.git // after $ git remote set-url origin https://github.com/acme/repo.git
Defensive patterns
Strategy: validation
Validate before calling
import subprocess
from urllib.parse import urlparse
def origin_matches_repo(repo_dir: str, expected_repo: str) -> bool:
r = subprocess.run(["git", "-C", repo_dir, "remote", "get-url", "origin"],
capture_output=True, text=True, check=False)
if r.returncode != 0:
return False
path = urlparse(r.stdout.strip()).path.strip("/")
if path.endswith(".git"):
path = path[:-4]
return path.lower() == expected_repo.lower() Try / catch
from fastapi import HTTPException
try:
result = client.post("/git/op", json={"repo": "acme/repo"})
except HTTPException as e:
if e.status_code == 400 and "does not match repo" in e.detail:
reassociate_worktree(worktree_dir, "acme/repo") # correct repo or request
else:
raise Prevention
- Keep a 1:1 mapping between worktrees and repos; never reuse a fork's worktree for the upstream repo
- Include the repo slug in worktree directory names to prevent mixups
- Verify `git remote get-url origin` matches the requested repo before proxy calls
- Update remotes after repo renames on GitHub
When it happens
Trigger: Proxied git op for expected_repo X where the worktree origin path resolves to Y — e.g. a fork (acme/repo-fork), a typo in owner/name, wrong case handling (path compares lowercased so only actual name mismatches count), or the worktree's origin was re-pointed at a mirror.
Common situations: Reusing a worktree cloned from a fork or a different project for a proxy request for another repo; renamed/moved repos where the remote still shows the old slug; misconfigured proxy request payload naming the wrong expected_repo.
Related errors
- remote url must be https://github.com/{expected_repo}[.git]
- remote url has invalid port
- remote url must not specify a port
- remote url host must be github.com for repo {expected_repo!r
- remote url must not contain params, query, or fragment
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/c647e20553dcb991.
Report an issue: GitHub.