{"record":{"id":"d9e9b5347adad801","repo":"invoke-ai/InvokeAI","slug":"file-extension-path-suffix-is-not-a-recognized-m","errorCode":null,"errorMessage":"File extension {path.suffix} is not a recognized model format. Expected one of: {extensions}","messagePattern":"File extension (.+?) is not a recognized model format\\. Expected one of: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/configs/factory.py","lineNumber":564,"sourceCode":"\n    @staticmethod\n    def _validate_path_looks_like_model(path: Path) -> None:\n        \"\"\"Perform basic sanity checks to ensure a path looks like a model.\n\n        This prevents wasting time trying to identify obviously non-model paths like\n        home directories or downloads folders. Raises RuntimeError if the path doesn't\n        pass basic checks.\n\n        Args:\n            path: The path to validate\n\n        Raises:\n            ValueError: If the path doesn't look like a model\n        \"\"\"\n        if path.is_file():\n            # For files, just check the extension\n            if path.suffix.lower() not in _MODEL_EXTENSIONS:\n                raise ValueError(\n                    f\"File extension {path.suffix} is not a recognized model format. \"\n                    f\"Expected one of: {', '.join(sorted(_MODEL_EXTENSIONS))}\"\n                )\n        else:\n            # Recognized Diffusers/Transformers configs are safe model markers. A generic config.json\n            # is not sufficient because many large application directories contain one.\n            recognized_root_config = False\n            for config_name in _CONFIG_FILES:\n                config_path = path / config_name\n                if not config_path.exists():\n                    continue\n                try:\n                    # Model config.json files are UTF-8; read explicitly so a non-ASCII value does not\n                    # raise UnicodeDecodeError under a cp1252 (Windows) locale and get mis-treated as\n                    # \"unrecognized\", which would wrongly reject a valid model directory.\n                    config = json.loads(config_path.read_text(encoding=\"utf-8\"))\n                except (OSError, ValueError):\n                    continue","sourceCodeStart":546,"sourceCodeEnd":582,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/factory.py#L546-L582","documentation":"_validate_path_looks_like_model pre-checks the path before probing. For a single file, the extension must be in _MODEL_EXTENSIONS (known weights formats). An unrecognized suffix (e.g. .json alone, .txt, .pth2, no extension) raises this ValueError so generic application directories aren't misinterpreted as models.","triggerScenarios":"Calling model install/probe APIs (from_model_on_disk path) with a file whose suffix is not a recognized model extension — e.g. pointing at a README, a config .json file, a .partial download, or an extensionless binary.","commonSituations":"Passing a transformers config.json directly instead of the weights file; incomplete downloads left with temp extensions; choosing the wrong file inside a model repo folder; typo'd extension after manual rename.","solutions":["Point at the actual weights file (.safetensors, .ckpt, .bin, etc.) instead of the config/README","Rename the file with a recognized model extension if it truly is weights saved with a wrong suffix","Check for incomplete downloads (e.g. .part/.tmp) and re-download fully","For diffusers-style models, pass the parent directory containing the config plus weights, not the config file alone"],"exampleFix":"// before\ninstall_model(\"/models/my-model/config.json\")\n// after\ninstall_model(\"/models/my-model/diffusion_pytorch_model.safetensors\")\n# or the directory:\ninstall_model(\"/models/my-model\")","handlingStrategy":"validation","validationCode":"import pathlib\n\n_MODEL_EXTENSIONS = {\".safetensors\", \".ckpt\", \".pt\", \".bin\", \".pth\", \".gguf\"}\n\ndef validate_model_file(path: str) -> pathlib.Path:\n    p = pathlib.Path(path)\n    if p.is_file() and p.suffix.lower() not in _MODEL_EXTENSIONS:\n        raise ValueError(f\"{p.suffix} is not a model extension; pass a weights file or model directory\")\n    return p","typeGuard":"def is_model_file(path: str) -> bool:\n    from invokeai.backend.model_manager.configs.factory import _MODEL_EXTENSIONS\n    p = pathlib.Path(path)\n    return p.is_file() and p.suffix.lower() in _MODEL_EXTENSIONS","tryCatchPattern":"try:\n    install_model(path)\nexcept ValueError as e:\n    if \"not a recognized model format\" in str(e):\n        logger.error(\"Point at a weights file (.safetensors/.ckpt/...) or its directory\")\n    else:\n        raise","preventionTips":["Never pass config.json, README or download stubs to the installer","Finish downloads before importing (no .part/.tmp files)","Use directory imports for diffusers-style repos","Check file extensions in your import UI before calling the API"],"tags":["python","file-extension","model-probing","validation"],"backgroundTag":"unsupported-file-extension","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}