{"record":{"id":"8d82be13dc476439","repo":"can1357/oh-my-pi","slug":"remote-url-host-must-be-github-com-for-repo-expec","errorCode":null,"errorMessage":"remote url host must be github.com for repo {expected_repo!r}","messagePattern":"remote url host must be github\\.com for repo (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"python/robomp/src/proxy/server.py","lineNumber":328,"sourceCode":"        raise HTTPException(400, f\"origin must have exactly one {kind} url\")\n    return urls[0]\n\n\ndef _normalized_github_https_url(url: str, expected_repo: str) -> str:\n    _validate_repo_name(expected_repo)\n    parsed = urlparse(url)\n    if (parsed.scheme or \"\").lower() != \"https\":\n        raise HTTPException(400, f\"remote url must be https://github.com/{expected_repo}[.git]\")\n    if parsed.username or parsed.password:\n        raise HTTPException(400, \"remote url must not contain embedded credentials\")\n    try:\n        port = parsed.port\n    except ValueError as exc:\n        raise HTTPException(400, \"remote url has invalid port\") from exc\n    if port is not None:\n        raise HTTPException(400, \"remote url must not specify a port\")\n    if (parsed.hostname or \"\").lower() != \"github.com\":\n        raise HTTPException(400, f\"remote url host must be github.com for repo {expected_repo!r}\")\n    if parsed.params or parsed.query or parsed.fragment:\n        raise HTTPException(400, \"remote url must not contain params, query, or fragment\")\n    path = parsed.path.strip(\"/\")\n    if path.endswith(\".git\"):\n        path = path[:-4]\n    if path.lower() != expected_repo.lower():\n        raise HTTPException(400, f\"remote url does not match repo {expected_repo!r}\")\n    return _github_url_for_repo(expected_repo)\n\n\ndef _remote_auth_for_url(url: str, expected_repo: str, token: str) -> _RemoteAuth:\n    raw = url.strip()\n    if not raw or raw != url:\n        raise HTTPException(400, \"remote url must not be empty or padded\")\n    if _FORBIDDEN_URL_BYTES_RE.search(raw):\n        raise HTTPException(400, \"remote url contains forbidden control bytes\")\n    if raw.startswith(\"-\"):\n        raise HTTPException(400, \"remote url must not start with '-'\")","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/python/robomp/src/proxy/server.py#L310-L346","documentation":"Raised when the origin URL is valid HTTPS but its hostname is not github.com. The proxy authenticates only against public GitHub (github.com); other hosts (GitHub Enterprise, gitlab, internal mirrors, typo'd hosts) are rejected with the expected repo name in the message to aid diagnosis.","triggerScenarios":"Proxied git op where urlparse(origin).hostname != 'github.com' (case-insensitive) — e.g. ghe.example.com, github.company.internal, ssh converted URLs pointing at a fork host, or hosts like www.github.com.","commonSituations":"Worktrees cloned from GitHub Enterprise or a mirror; DNS/search-domain appending producing gitlab.com vs github.com mixups; proxies rewriting the host; typo'd hostnames.","solutions":["Point origin at github.com: `git remote set-url origin https://github.com/<owner>/<repo>.git`","If the repo truly lives on another host, this proxy does not support it — use direct git instead","Check for insteadOf rewrites rewriting the host (`git config --get-regexp url\\..*\\.insteadof`)","Remove host-rewriting HTTPS_PROXY/hosts-file tricks that alter the effective hostname"],"exampleFix":"// before (enterprise host)\n$ git remote set-url origin https://ghe.acme.internal/acme/repo.git\n// after\n$ git remote set-url origin https://github.com/acme/repo.git","handlingStrategy":"validation","validationCode":"from urllib.parse import urlparse\n\ndef origin_host_is_github(url: str) -> bool:\n    return (urlparse(url).hostname or \"\").lower() == \"github.com\"","typeGuard":null,"tryCatchPattern":"from fastapi import HTTPException\n\ntry:\n    result = client.post(\"/git/op\", json={\"repo\": \"acme/repo\"})\nexcept HTTPException as e:\n    if e.status_code == 400 and \"host must be github.com\" in e.detail:\n        set_origin(worktree_dir, f\"https://github.com/{expected_repo}.git\")\n    else:\n        raise","preventionTips":["Route only github.com repos through the proxy; keep GHE/mirrors on direct git","Audit insteadOf rewrites that substitute internal hostnames","Provision remotes from a canonical template, not from clone-time hosts"],"tags":["git","remote-url","proxy","github"],"backgroundTag":"wrong-git-remote-host","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}