can1357/oh-my-pi · error · HTTPException

remote url must not specify a port

Error message

remote url must not specify a port

What it means

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.

Source

Thrown at python/robomp/src/proxy/server.py:326

            extra={"expected_repo": expected_repo, "kind": kind, "count": len(urls)},
        )
        raise HTTPException(400, f"origin must have exactly one {kind} url")
    return urls[0]


def _normalized_github_https_url(url: str, expected_repo: str) -> str:
    _validate_repo_name(expected_repo)
    parsed = urlparse(url)
    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")

View on GitHub (pinned to 9690622007)

Solutions

  1. Remove the port: `git remote set-url origin https://github.com/<owner>/<repo>.git` (443 is implicit for https)
  2. If a custom port is genuinely required, you are likely pointing at GitHub Enterprise — that host is out of scope for this proxy
  3. Confirm reachability of https://github.com without a port suffix

Example fix

// before
$ git remote set-url origin https://github.com:443/acme/repo.git
// after
$ git remote set-url origin https://github.com/acme/repo.git
Defensive patterns

Strategy: validation

Validate before calling

from urllib.parse import urlparse

def origin_has_no_explicit_port(url: str) -> bool:
    return urlparse(url).port is None

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 "must not specify a port" in e.detail:
        set_origin(worktree_dir, f"https://github.com/{expected_repo}.git")
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/c65212a35f343ae8. Report an issue: GitHub.