{"record":{"id":"ee4b498d22083372","repo":"unslothai/unsloth","slug":"invalid-model-snapshot-repository-id","errorCode":null,"errorMessage":"Invalid model snapshot repository ID.","messagePattern":"Invalid model snapshot repository ID\\.","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"studio/backend/routes/models.py","lineNumber":2311,"sourceCode":"        )\n\n        local_model = is_local_path(model_name)\n        if not local_model:\n            model_name = resolve_cached_repo_id_case(model_name)\n        scan_target = model_name\n        exact_snapshot_path = (\n            model_snapshot_path.strip()\n            if isinstance(model_snapshot_path, str) and model_snapshot_path.strip()\n            else None\n        )\n        exact_snapshot_repo_id = model_name\n        if isinstance(model_snapshot_repo_id, str):\n            snapshot_repo_id = model_snapshot_repo_id.strip()\n            # Namespace-less Hub ids like \"gpt2\" are valid, so use the shared validator, not the regex.\n            from hub.utils.paths import is_valid_repo_id as _shared_is_valid_repo_id\n\n            if snapshot_repo_id and not _shared_is_valid_repo_id(snapshot_repo_id):\n                raise HTTPException(\n                    status_code = 400,\n                    detail = \"Invalid model snapshot repository ID.\",\n                )\n            if snapshot_repo_id:\n                exact_snapshot_repo_id = snapshot_repo_id\n        if local_model:\n            normalized_model_name = normalize_path(model_name)\n            try:\n                scan_target = str(Path(normalized_model_name).expanduser().resolve(strict = False))\n            except (OSError, RuntimeError, ValueError):\n                scan_target = normalized_model_name\n        if exact_snapshot_path and not local_model:\n            exact_snapshot_repo_id = resolve_cached_repo_id_case(exact_snapshot_repo_id)\n            scan_target = _model_config_inspection_target(\n                exact_snapshot_repo_id,\n                True,\n                normalize_path(exact_snapshot_path),\n            )","sourceCodeStart":2293,"sourceCodeEnd":2329,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/routes/models.py#L2293-L2329","documentation":"Raised as a 400 by the model-config endpoint when the optional model_snapshot_repo_id query/body parameter, after stripping whitespace, fails the shared hub validator is_valid_repo_id (imported from hub.utils.paths). Namespace-less ids like 'gpt2' are valid, so the check is the shared validator rather than a strict namespace regex — but malformed ids (bad characters, empty-ish segments, bad separators) are rejected.","triggerScenarios":"GET /api/models/config/... with model_snapshot_repo_id containing invalid characters (spaces, backslashes), malformed separators, leading/trailing slashes after strip(), or a repo id shape the shared validator rejects.","commonSituations":"Front-end passing a local filesystem path where a Hub repo id is expected; copy-paste artifacts (whitespace, unicode dashes); case/format drift after a Hub rename.","solutions":["Send a well-formed Hub repo id such as 'org/repo-name' or a namespace-less 'gpt2' — no scheme, no absolute path, no spaces.","Trim whitespace client-side before sending (the server strips, but embedded bad characters still fail).","If you meant a local path, pass it via the local-path/local_model parameters instead of model_snapshot_repo_id."],"exampleFix":"# before\nclient.get('/api/models/config/MyModel', params={'model_snapshot_repo_id': 'C:\\models\\MyModel'})  # 400\n\n# after\nclient.get('/api/models/config/MyModel', params={'model_snapshot_repo_id': 'org/my-model'})","handlingStrategy":"type-guard","validationCode":"const REPO_ID_RE = /^[\\w.-]+(\\/[\\w.-]+)?$/;\nfunction isValidRepoId(v: string | undefined): v is string {\n  return typeof v === 'string' && REPO_ID_RE.test(v.trim()) && v.trim().length > 0;\n}\nif (snapshotRepoId !== undefined && !isValidRepoId(snapshotRepoId)) {\n  throw new Error('model_snapshot_repo_id must be a Hub repo id like org/repo or gpt2');\n}","typeGuard":"function isValidRepoId(v: unknown): v is string {\n  return typeof v === 'string'\n    && /^[\\w.-]+(\\/[\\w.-]+)?$/.test(v.trim())\n    && !v.trim().startsWith('/')\n    && !v.trim().endsWith('/');\n}","tryCatchPattern":"try {\n  cfg = client.get(url, params=params)\nexcept HTTPError as e:\n    if e.response.status_code == 400 and 'repository ID' in e.response.json()['detail']:\n        params.pop('model_snapshot_repo_id')  # retry with the model_name default\n        cfg = client.get(url, params=params)\n    else: raise","preventionTips":["Send Hub repo ids (org/name or bare name), never filesystem paths, in model_snapshot_repo_id.","Trim client-side and reject ids containing spaces, backslashes, or drive letters before the call.","Remember namespace-less ids like 'gpt2' are legal — validate shape, not presence of a slash."],"tags":["models","huggingface","validation","repo-id","api"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}