{"record":{"id":"3bafdea496a51f92","repo":"invoke-ai/InvokeAI","slug":"model-path-is-not-a-file","errorCode":null,"errorMessage":"model path is not a file","messagePattern":"model path is not a file","errorType":"validation","errorClass":"NotAMatchError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/configs/identification_utils.py","lineNumber":160,"sourceCode":"        candidate_config_class: The config class that is being tested.\n        override_fields: The override fields provided by the user.\n\n    Raises:\n        NotAMatch if any override field is invalid for the config class.\n    \"\"\"\n    for field_name, override_value in override_fields.items():\n        if field_name not in candidate_config_class.model_fields:\n            raise NotAMatchError(f\"unknown override field: {field_name}\")\n        try:\n            PydanticFieldValidator.validate_field(candidate_config_class, field_name, override_value)\n        except ValidationError as e:\n            raise NotAMatchError(f\"invalid override for field '{field_name}': {e}\") from e\n\n\ndef raise_if_not_file(mod: ModelOnDisk) -> None:\n    \"\"\"Raise NotAMatch if the model path is not a file.\"\"\"\n    if not mod.path.is_file():\n        raise NotAMatchError(\"model path is not a file\")\n\n\ndef raise_if_not_dir(mod: ModelOnDisk) -> None:\n    \"\"\"Raise NotAMatch if the model path is not a directory.\"\"\"\n    if not mod.path.is_dir():\n        raise NotAMatchError(\"model path is not a directory\")\n\n\ndef state_dict_has_any_keys_exact(state_dict: dict[str | int, Any], keys: str | set[str]) -> bool:\n    \"\"\"Returns true if the state dict has any of the specified keys.\"\"\"\n    _keys = {keys} if isinstance(keys, str) else keys\n    return any(key in state_dict for key in _keys)\n\n\ndef state_dict_has_any_keys_starting_with(state_dict: dict[str | int, Any], prefixes: str | set[str]) -> bool:\n    \"\"\"Returns true if the state dict has any keys starting with any of the specified prefixes.\"\"\"\n    _prefixes = {prefixes} if isinstance(prefixes, str) else prefixes\n    return any(any(key.startswith(prefix) for prefix in _prefixes) for key in state_dict.keys() if isinstance(key, str))","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/identification_utils.py#L142-L178","documentation":"raise_if_not_file asserts that the ModelOnDisk path is a regular file. Config classes that represent single-file model formats (e.g. single checkpoint files) call this during from_model_on_disk probing; if the path is a directory (or a nonexistent/special file), NotAMatchError is raised so the next candidate config can be tried.","triggerScenarios":"from_model_on_disk probing a single-file model config against a directory path (or vice versa), e.g. scanning a diffusers-style folder with a checkpoint-file config class.","commonSituations":"Registering a folder of weights instead of the .safetensors/.ckpt file itself; path points to a directory containing the model rather than the model; broken symlinks to files.","solutions":["Verify the path with os.path.isfile(); point it at the actual weights file (e.g. model.safetensors).","If the model is a diffusers directory, use the directory config class instead of the single-file one.","Fix broken symlinks so the path resolves to a real file.","Rescan the models directory if InvokeAI's cached path metadata is stale."],"exampleFix":"// before\nModelOnDisk(Path(\"/models/sd15/\"))  # directory\n// after\nModelOnDisk(Path(\"/models/sd15/v1-5-pruned-emaonly.safetensors\"))","handlingStrategy":"validation","validationCode":"from pathlib import Path\np = Path(model_path)\nassert p.is_file(), f\"expected a single-file model, got: {p}\"","typeGuard":"def is_model_file(p) -> bool:\n    from pathlib import Path\n    return Path(p).is_file() and Path(p).suffix in {\".safetensors\", \".ckpt\", \".bin\"}","tryCatchPattern":"try:\n    record = from_model_on_disk(mod)\nexcept NotAMatchError as e:\n    if str(e) == \"model path is not a file\":\n        logger.warning(\"skipping directory path with single-file config: %s\", mod.path)","preventionTips":["Check path kind (file vs dir) before choosing which config class to probe","Resolve symlinks with Path.resolve() before registration","Keep single-file checkpoints and diffusers folders in separate scan roots"],"tags":["filesystem","path","invokeai"],"backgroundTag":"path-is-not-a-file","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}