{"record":{"id":"498fbaddc9cc3072","repo":"unslothai/unsloth","slug":"invalid-repo-id-repo-id-r","errorCode":null,"errorMessage":"Invalid repo_id: {repo_id!r}","messagePattern":"Invalid repo_id: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"studio/backend/hub/services/datasets/downloads.py","lineNumber":159,"sourceCode":"        variant = None,\n    )\n    return DatasetDownloadJobStatus(state = state, error = error, generation = generation)\n\n\nasync def download_dataset_response(\n    body: DownloadDatasetRequest,\n    hf_token: Optional[str] = None,\n    *,\n    allow_ambient_token: bool = True,\n) -> dict:\n    \"\"\"Start a background download for a HuggingFace dataset.\n\n    ``allow_ambient_token=False`` keeps the worker anonymous when the caller sent no token, for\n    repos named over the API rather than chosen here.\n    \"\"\"\n    repo_id = body.repo_id.strip()\n    if not _is_valid_repo_id(repo_id):\n        raise HTTPException(\n            status_code = 400,\n            detail = f\"Invalid repo_id: {repo_id!r}\",\n        )\n    # Canonicalize so two different-cased paste-ins share one job + cache dir.\n    repo_id = await asyncio.to_thread(resolve_cached_repo_id_case, repo_id, repo_type = \"dataset\")\n    key = _download_job_key(repo_id)\n\n    # Off the event loop: resolving \"auto\" can run the Xet reachability probe, and a blackholed DNS\n    # makes that outlast its 3s budget while every other Studio request waits behind it.\n    use_xet, transport_reason = await asyncio.to_thread(\n        download_lifecycle.resolve_requested_use_xet,\n        getattr(body, \"transport_mode\", None),\n        body.use_xet,\n    )\n    transport = download_lifecycle.resolve_transport(use_xet)\n    logger.info(\"Download transport for %s: %s (%s)\", repo_id, transport, transport_reason)\n    from utils.hf_cache_settings import get_hf_cache_paths\n","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/hub/services/datasets/downloads.py#L141-L177","documentation":"HTTP 400 from the start-dataset-download endpoint when the submitted repo_id fails the `_is_valid_repo_id` check after stripping whitespace. The validator enforces the HuggingFace `namespace/name` shape (or bare name) and rejects empty strings, bad characters, or malformed paths before any network work happens.","triggerScenarios":"POSTing a download request with an empty repo_id, leading/trailing-only whitespace, embedded '..' or slashes in the wrong places, or non-ASCII/control characters that do not match the repo-id grammar.","commonSituations":"Form submitted before the user finished typing; pasted URL (`https://huggingface.co/datasets/foo/bar`) instead of the repo id; copy-paste introduced a trailing newline or invisible character.","solutions":["Send the canonical repo id (`owner/dataset` or `dataset`), not a full huggingface.co URL.","Trim the input client-side and reject empty values before submitting.","Mirror the same repo-id grammar client-side (namespace/name, [A-Za-z0-9_.-]) to fail fast.","If the id looks right, log the repr — the f-string uses {repo_id!r}, so hidden characters will show up quoted."],"exampleFix":"# before\nbody = DownloadDatasetRequest(repo_id=\"https://huggingface.co/datasets/squad\")\n# after\nbody = DownloadDatasetRequest(repo_id=\"squad\")","handlingStrategy":"validation","validationCode":"import re\nREPO_ID_RE = re.compile(r\"^[A-Za-z0-9_.-]+(/[A-Za-z0-9_.-]+)?$\")\n\ndef is_valid_repo_id(repo_id: str) -> bool:\n    repo_id = repo_id.strip()\n    return bool(repo_id) and len(repo_id) <= 96 and bool(REPO_ID_RE.match(repo_id))","typeGuard":"def is_download_request_valid(body) -> TypeGuard[DownloadDatasetRequest]:\n    return isinstance(body.repo_id, str) and is_valid_repo_id(body.repo_id)","tryCatchPattern":"try:\n    start_download(client, body)\nexcept HTTPStatusError as e:\n    if e.response.status_code == 400:\n        show_field_error(\"repo_id\", e.response.json()[\"detail\"])  # includes !r repr: reveals hidden chars\n    else:\n        raise","preventionTips":["Validate the repo-id grammar client-side with the same regex before enabling the Download button.","Strip whitespace and reject empty input at the form layer.","If users paste URLs, extract the `datasets/<repo_id>` segment automatically."],"tags":["validation","huggingface","repo-id","http-400"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}