{"record":{"id":"afd5f8ecdfbcf68b","repo":"abhigyanpatwari/GitNexus","slug":"model-base-url-must-be-an-http-s-endpoint-without","errorCode":null,"errorMessage":"model base URL must be an HTTP(S) endpoint without credentials, query, or fragment","messagePattern":"model base URL must be an HTTP\\(S\\) endpoint without credentials, query, or fragment","errorType":"validation","errorClass":"SandboxError","httpStatus":null,"severity":"error","filePath":"eval/workflow_bench/proposer_sandbox.py","lineNumber":257,"sourceCode":"            path.chmod(0o600)\n    except BaseException:\n        shutil.rmtree(destination, ignore_errors=True)\n        raise\n    return destination\n\n\ndef _validated_base_url(base_url: str) -> str:\n    value = base_url.strip()\n    parsed = urlsplit(value)\n    if (\n        parsed.scheme not in {\"http\", \"https\"}\n        or not parsed.hostname\n        or parsed.username is not None\n        or parsed.password is not None\n        or parsed.query\n        or parsed.fragment\n    ):\n        raise SandboxError(\"model base URL must be an HTTP(S) endpoint without credentials, query, or fragment\")\n    return value\n\n\ndef build_sandbox_environment(\n    *,\n    auth_token: str | None = None,\n    base_url: str | None = None,\n) -> dict[str, str]:\n    \"\"\"Build the entire parent environment; never copy ``os.environ``.\"\"\"\n\n    env = {\n        \"HOME\": SANDBOX_HOME,\n        \"USER\": \"agent\",\n        \"LOGNAME\": \"agent\",\n        \"TMPDIR\": SANDBOX_TMP,\n        \"XDG_CONFIG_HOME\": f\"{SANDBOX_HOME}/.config\",\n        \"XDG_CACHE_HOME\": f\"{SANDBOX_HOME}/.cache\",\n        \"XDG_STATE_HOME\": f\"{SANDBOX_HOME}/.local/state\",","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/proposer_sandbox.py#L239-L275","documentation":"Raised by _validated_base_url when a model base URL is not a clean HTTP(S) endpoint. The validator (urlsplit) requires scheme http/https, a non-empty hostname, and no username, password, query, or fragment. This prevents credentials leaking into the URL, ambient query params, or fragment tricks reaching the model endpoint inside the sandbox.","triggerScenarios":"Passing base_url to build_sandbox_environment with a non-http(s) scheme (file://, unix://), a URL with embedded user:pass@host, a URL carrying ?query or #fragment, or a URL with no hostname (e.g. 'http:///path').","commonSituations":"base_url read from an env var or config that included an API key as userinfo; a proxy URL with ?api_key=... in the query string; mistyped scheme (htps); localhost-with-port URLs that accidentally carried a fragment from a docs page; file:/// or mock-server URL used in tests.","solutions":["Strip credentials out of the URL and pass the token via auth_token instead.","Remove query and fragment; move any needed params into headers/body at the call site.","Ensure the scheme is exactly http or https and a hostname is present.","For local mock servers use http://127.0.0.1:PORT with no extras."],"exampleFix":"// before\nbuild_sandbox_environment(base_url='https://user:pass@api.example.com?beta=1#x')\n// after\nbuild_sandbox_environment(auth_token='pass', base_url='https://api.example.com')","handlingStrategy":"validation","validationCode":"from urllib.parse import urlsplit\n\ndef is_clean_http_url(url: str) -> bool:\n    p = urlsplit(url.strip())\n    return (p.scheme in {'http','https'}\n            and bool(p.hostname)\n            and p.username is None\n            and p.password is None\n            and not p.query\n            and not p.fragment)\n\nif not is_clean_http_url(base_url):\n    raise ValueError(f'invalid base_url: {base_url!r}')","typeGuard":"from urllib.parse import urlsplit\n\ndef is_clean_http_endpoint(url: object) -> bool:\n    if not isinstance(url, str):\n        return False\n    p = urlsplit(url.strip())\n    return (p.scheme in {'http','https'}\n            and bool(p.hostname)\n            and p.username is None\n            and p.password is None\n            and not p.query\n            and not p.fragment)","tryCatchPattern":"try:\n    env = build_sandbox_environment(auth_token=tok, base_url=base_url)\nexcept SandboxError as exc:\n    if 'HTTP(S) endpoint' in str(exc):\n        base_url = strip_userinfo_query_fragment(base_url)\n        env = build_sandbox_environment(auth_token=tok, base_url=base_url)\n    raise","preventionTips":["Keep credentials out of URLs; pass tokens via auth_token.","Validate base_url with urlsplit at config load.","Reject query/fragment in endpoint config.","Use http(s)://host[:port] only."],"tags":["network","url-validation","security","sandbox"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}