can1357/oh-my-pi · error · HTTPException
remote url must not be empty or padded
Error message
remote url must not be empty or padded
What it means
The GitHub proxy validates every remote URL before handing it to git. A URL that is empty after no-strip-difference or differs from its stripped form (leading/trailing whitespace) is rejected with HTTP 400, because padded URLs cause git argument/credential confusion and empty URLs are meaningless. This guard runs in _remote_auth_for_url, used by both clone and origin-remote auth paths.
Source
Thrown at python/robomp/src/proxy/server.py:342
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)
def _clone_remote_auth(clone_url: str, expected_repo: str, token: str) -> _RemoteAuth:
try:
return _remote_auth_for_url(clone_url, expected_repo, token)
except HTTPException:
log.warning(View on GitHub (pinned to 9690622007)
Solutions
- Trim the URL before sending, e.g. url.strip(), and skip empty values entirely
- Fix the config file or env var so the value has no surrounding whitespace or newlines
- If the URL comes from a subprocess/file read, use .strip() on the captured output
Example fix
// before
clone({ "repo": " https://github.com/org/repo.git " })
// after
const url = (process.env.REPO_URL ?? "").trim();
if (url) clone({ repo: url }); Defensive patterns
Strategy: validation
Validate before calling
const trimmed = (url ?? "").trim();
if (!trimmed) throw new Error("remote url is empty");
if (trimmed !== url) throw new Error(`remote url has padding: ${JSON.stringify(url)}`); Type guard
function isCleanUrl(u: unknown): u is string {
return typeof u === "string" && u.length > 0 && u === u.trim();
} Prevention
- Always .trim() URLs read from env vars, config files, or subprocess output
- Use structured config parsers that strip scalar values
- Fail fast on empty values instead of forwarding them
When it happens
Trigger: Calling an endpoint that resolves to _clone_remote_auth or _origin_remote_auth with a repo/remote URL that is '' or contains leading/trailing spaces, tabs, or newlines (e.g. ' https://github.com/o/r.git').
Common situations: YAML or env config values picking up trailing whitespace/newlines; string concatenation adding a stray space; shell scripts capturing 'git config --get remote.origin.url' output without trimming; empty placeholder values in CI templates.
Related errors
- missing/invalid 'slot_uid'
- invalid '{field}': must be array of strings
- missing/invalid 'comments'
- comments[{idx}] must be an object
- comments[{idx}].side must be RIGHT or LEFT
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/2e122f383a522573.
Report an issue: GitHub.