{"record":{"id":"079b63e22a4759cd","repo":"invoke-ai/InvokeAI","slug":"unsupported-model-source-source","errorCode":null,"errorMessage":"Unsupported model source: '{source}'","messagePattern":"Unsupported model source: '(.+?)'","errorType":"exception","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"invokeai/app/services/model_install/model_install_default.py","lineNumber":898,"sourceCode":"            external_id = source_stripped.removeprefix(\"external://\")\n            provider_id, _, provider_model_id = external_id.partition(\"/\")\n            if not provider_id or not provider_model_id:\n                raise ValueError(f\"Invalid external model source: '{source_stripped}'\")\n            source_obj = ExternalModelSource(provider_id=provider_id, provider_model_id=provider_model_id)\n        elif Path(source_stripped).exists():  # A local file or directory\n            source_obj = LocalModelSource(path=Path(source_stripped))\n        elif match := re.match(hf_repoid_re, source):\n            source_obj = HFModelSource(\n                repo_id=match.group(1),\n                variant=ModelRepoVariant(match.group(2)) if match.group(2) else None,  # pass None rather than ''\n                subfolder=Path(match.group(3)) if match.group(3) else None,\n            )\n        elif re.match(r\"^https?://[^/]+\", source):\n            source_obj = URLModelSource(\n                url=Url(source),\n            )\n        else:\n            raise ValueError(f\"Unsupported model source: '{source}'\")\n        return source_obj\n\n    # --------------------------------------------------------------------------------------------\n    # Internal functions that manage the installer threads\n    # --------------------------------------------------------------------------------------------\n    def _start_installer_thread(self) -> None:\n        self._install_thread = threading.Thread(target=self._install_next_item, daemon=True)\n        self._install_thread.start()\n        self._running = True\n\n    @staticmethod\n    def _safe_rmtree(path: Path, logger: Any) -> None:\n        \"\"\"Remove a directory tree with retry logic for Windows file locking issues.\n\n        On Windows, memory-mapped files may not be immediately released even after\n        the file handle is closed. This function retries the removal with garbage\n        collection to help release any lingering references.\n        \"\"\"","sourceCodeStart":880,"sourceCodeEnd":916,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/services/model_install/model_install_default.py#L880-L916","documentation":"_guess_source() is the catch-all parser for model source strings. After checking external://, local paths, HuggingFace repo ids, and repo-file patterns, it treats only http(s) URLs as URLModelSource. Anything else raises ValueError('Unsupported model source: ...'), meaning the string matches none of the recognized source patterns.","triggerScenarios":"Passing a bare model name not matching the HF repoid regex (no 'org/name' shape); ftp:// or other non-http URLs; typo'd repoids like 'authorname' without slash; Windows paths with backslashes that don't exist as local paths on this machine.","commonSituations":"Users pasting a model page slug like 'stable-diffusion-v1-5' without the owner prefix; scripts passing 's3://bucket/model' or 'file:///...' URIs; local path that exists on the user's machine but not the server's filesystem.","solutions":["Use a fully qualified HuggingFace repo id 'org/repo' (optionally ':variant:subfolder').","For downloads, use an http(s) URL to the file or repo.","If it's a local model, ensure the path exists on the machine running the service and is absolute.","Or construct the appropriate ModelSource object explicitly (HFModelSource/URLModelSource/LocalModelSource) instead of a string."],"exampleFix":"// before\nservice.heuristic_import('stable-diffusion-v1-5')\n// after\nservice.heuristic_import('stable-diffusion-v1-5/stable-diffusion-v1-5')  # or full https URL / existing local path","handlingStrategy":"validation","validationCode":"import re, os\nHF_RE = re.compile(r'^[^/:]+/[^/:]+')\nok = bool(HF_RE.match(s) or re.match(r'^https?://', s) or (os.path.exists(s.strip('\"'))))","typeGuard":"def is_recognizable_source(s: str) -> bool:\n    s2 = s.strip('\"')\n    return (s2.startswith('external://')\n            or os.path.exists(s2)\n            or bool(re.match(r'^[^/:]+/[^/:]+', s))\n            or bool(re.match(r'^https?://', s)))","tryCatchPattern":"try:\n    source_obj = service.heuristic_import(user_string)\nexcept ValueError as e:\n    if 'Unsupported model source' in str(e):\n        source_obj = HFModelSource(repo_id=f'owner/{user_string}')  # normalize bare names","preventionTips":["Always pass HF sources as 'owner/repo', never a bare model name.","Use http(s) URLs only; convert s3:// or file:// URIs beforehand.","Ensure local paths exist on the service host, not just the client.","When in doubt, construct an explicit ModelSource object instead of a string."],"tags":["validation","parsing","model-source"],"backgroundTag":"invalid-model-source-format","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}