{"record":{"id":"a42acc2b868916df","repo":"odysseus-dev/odysseus","slug":"invalid-repo-id-must-be-org-name-an-ollama","errorCode":null,"errorMessage":"Invalid repo_id — must be <org>/<name>, an Ollama name:tag, or a cached local model id","messagePattern":"Invalid repo_id — must be <org>/<name>, an Ollama name:tag, or a cached local model id","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"routes/cookbook_helpers.py","lineNumber":76,"sourceCode":"    m = re.match(r\"^([A-Za-z]):[\\\\/](.*)$\", path)\n    if not m:\n        return path\n    drive, rest = m.groups()\n    return f\"/{drive.lower()}/{rest.replace(chr(92), '/')}\"\n\n\ndef _validate_repo_id(v: str | None) -> str:\n    if not v or not _REPO_ID_RE.match(v):\n        raise HTTPException(400, \"Invalid repo_id — must be <org>/<name> using [A-Za-z0-9._-]\")\n    return v\n\n\ndef _validate_serve_model_id(v: str | None) -> str:\n    if not v:\n        raise HTTPException(400, \"repo_id is required\")\n    if _REPO_ID_RE.match(v) or _LOCAL_MODEL_ID_RE.match(v) or _OLLAMA_MODEL_ID_RE.match(v):\n        return v\n    raise HTTPException(400, \"Invalid repo_id — must be <org>/<name>, an Ollama name:tag, or a cached local model id\")\n\n\ndef _validate_include(v: str | None) -> str | None:\n    if v is None or v == \"\":\n        return None\n    if not _INCLUDE_RE.match(v):\n        raise HTTPException(400, \"Invalid include pattern\")\n    return v\n\n\ndef _validate_token(v: str | None) -> str | None:\n    if v is None or v == \"\":\n        return None\n    if not _TOKEN_RE.match(v):\n        raise HTTPException(400, \"Invalid token characters\")\n    return v\n\n","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/routes/cookbook_helpers.py#L58-L94","documentation":"HTTP 400 from _validate_serve_model_id() in routes/cookbook_helpers.py. The value must match one of three accepted shapes: _REPO_ID_RE (HF <org>/<name>), _LOCAL_MODEL_ID_RE (cached local model id), or _OLLAMA_MODEL_ID_RE (Ollama name:tag). Anything else — spaces, URLs, shell metacharacters, unusual punctuation — is rejected.","triggerScenarios":"POST serve with repo_id values like \"meta-llama/Meta-Llama-3-8B \" (trailing space), \"https://huggingface.co/org/name\", \"org/name;rm -rf\", or a local filesystem path that does not fit _LOCAL_MODEL_ID_RE.","commonSituations":"Users pasting HF URLs or local paths where an id is expected; whitespace from copy-paste; attempted command injection through the model field; sending a Docker-style image reference (org/repo:tag), which is not one of the three accepted grammars.","solutions":["Use an HF id (mistralai/Mistral-7B-Instruct-v0.2), an Ollama name:tag (llama3:8b), or a cached local model id exactly as the cache keys it","Strip whitespace and quotes before sending","Inspect _REPO_ID_RE, _LOCAL_MODEL_ID_RE and _OLLAMA_MODEL_ID_RE in routes/cookbook_helpers.py to see which shape your value violates","For a brand-new local model, download/register it first so it matches the cached-id grammar"],"exampleFix":"// before\n{\"repo_id\": \"models--meta-llama--Meta-Llama-3-8B/snapshots/abc123\"}\n// after\n{\"repo_id\": \"meta-llama/Meta-Llama-3-8B\"}","handlingStrategy":"validation","validationCode":"import re\nREPO = re.compile(r\"^[A-Za-z0-9._-]+/[A-Za-z0-9._-]+$\")\nOLLAMA = re.compile(r\"^[A-Za-z0-9._-]+:[A-Za-z0-9._-]+$\")\n\ndef classify_model_id(v: str):\n    v = (v or \"\").strip()\n    if REPO.match(v):\n        return \"hf\"\n    if OLLAMA.match(v):\n        return \"ollama\"\n    return None  # compare local cache keys separately\n\nif classify_model_id(rid) is None:\n    raise ValueError(f\"unsupported model id: {rid!r}\")","typeGuard":"function looksLikeModelId(v: string): boolean {\n  const t = v.trim();\n  return /^[\\w.-]+\\/[\\w.-]+$/.test(t) || /^[\\w.-]+:[\\w.-]+$/.test(t);\n}","tryCatchPattern":null,"preventionTips":["Trim the id before sending","Never paste URLs, paths, or image references into the model field","Mirror the three regexes (_REPO_ID_RE, _LOCAL_MODEL_ID_RE, _OLLAMA_MODEL_ID_RE) client-side"],"tags":["validation","serve","model-id","http-400"],"backgroundTag":null,"analyzedSha":"f9235ebbf13f693a6fd29ce70b097f6ec83705bf","analyzedAt":"2026-08-14T21:47:48.359Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}