{"record":{"id":"b6e78ec244d2cd22","repo":"can1357/oh-my-pi","slug":"remote-url-must-not-contain-params-query-or-frag","errorCode":null,"errorMessage":"remote url must not contain params, query, or fragment","messagePattern":"remote url must not contain params, query, or fragment","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"python/robomp/src/proxy/server.py","lineNumber":330,"sourceCode":"\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 '-'\")\n    if _REMOTE_HELPER_RE.match(raw):\n        raise HTTPException(400, \"git remote helper transports are disabled\")","sourceCodeStart":312,"sourceCodeEnd":348,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/python/robomp/src/proxy/server.py#L312-L348","documentation":"Raised when the origin URL contains a params, query string, or fragment component. GitHub remote URLs are plain paths; anything after '?' or '#' (or SVN-style ';params') means the URL is not canonical, so the proxy rejects it before constructing its own clean URL.","triggerScenarios":"Proxied git op where parsed.params or parsed.query or parsed.fragment is truthy — e.g. https://github.com/acme/repo.git?token=abc, ...repo.git#main, or legacy SCM-style URLs with ;param sections.","commonSituations":"Pasting a GitHub web URL (with ?tab=readme or #readme) as a remote; templating tools appending query tokens to the URL; copied URLs from docs containing anchors.","solutions":["Strip the suffix: set origin to `https://github.com/<owner>/<repo>.git` via `git remote set-url origin`","Never paste browser URLs (with ?/ #) as git remotes; use the clone button's HTTPS URL","Check for scripts/templating that append query parameters to remote URLs"],"exampleFix":"// before\n$ git remote set-url origin \"https://github.com/acme/repo.git?token=abc\"\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_url_is_clean(url: str) -> bool:\n    p = urlparse(url)\n    return not (p.params or p.query or p.fragment)","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 \"params, query, or fragment\" in e.detail:\n        set_origin(worktree_dir, f\"https://github.com/{expected_repo}.git\")\n    else:\n        raise","preventionTips":["Copy remotes from GitHub's 'Code → Clone → HTTPS' button, never the browser address bar","Never append tokens or tracking params to remote URLs","Validate URLs with urlparse before installing them as remotes in scripts"],"tags":["git","remote-url","url-parsing","proxy"],"backgroundTag":"non-canonical-remote-url","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}