{"record":{"id":"c65212a35f343ae8","repo":"can1357/oh-my-pi","slug":"remote-url-must-not-specify-a-port","errorCode":null,"errorMessage":"remote url must not specify a port","messagePattern":"remote url must not specify a port","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"python/robomp/src/proxy/server.py","lineNumber":326,"sourceCode":"            extra={\"expected_repo\": expected_repo, \"kind\": kind, \"count\": len(urls)},\n        )\n        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\")","sourceCodeStart":308,"sourceCodeEnd":344,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/python/robomp/src/proxy/server.py#L308-L344","documentation":"Raised when the origin URL includes an explicit port (e.g. https://github.com:443/acme/repo.git). The proxy only accepts the canonical https://github.com host with the default port, so any explicit port is rejected to keep the URL set strictly canonical.","triggerScenarios":"Proxied git op where urlparse(origin).port is not None — e.g. https://github.com:443/acme/repo.git or a GitHub Enterprise-style URL with a custom port.","commonSituations":"Copied URLs from behind a proxy/gateway that included :443 or :8443; GHE configs reused against github.com; internal mirrors exposing GitHub on nonstandard ports.","solutions":["Remove the port: `git remote set-url origin https://github.com/<owner>/<repo>.git` (443 is implicit for https)","If a custom port is genuinely required, you are likely pointing at GitHub Enterprise — that host is out of scope for this proxy","Confirm reachability of https://github.com without a port suffix"],"exampleFix":"// before\n$ git remote set-url origin https://github.com:443/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_has_no_explicit_port(url: str) -> bool:\n    return urlparse(url).port is None","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 \"must not specify a port\" in e.detail:\n        set_origin(worktree_dir, f\"https://github.com/{expected_repo}.git\")\n    else:\n        raise","preventionTips":["Rely on https' implicit port 443; omit ':443' from remote URLs","Don't reuse GitHub Enterprise URLs (custom ports) for github.com repos","Normalize URLs through one helper that strips ports before setting remotes"],"tags":["git","https","remote-url","proxy"],"backgroundTag":"non-canonical-remote-url","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}