{"record":{"id":"b7c40e4a078d2d1e","repo":"invoke-ai/InvokeAI","slug":"name","errorCode":null,"errorMessage":"{name}","messagePattern":"\\{name\\}","errorType":"exception","errorClass":"ObjectNotFoundError","httpStatus":null,"severity":"error","filePath":"invokeai/app/services/object_serializer/object_serializer_disk.py","lineNumber":58,"sourceCode":"            # Remove dangling tempdirs that might have been left over from an earlier unplanned shutdown.\n            for temp_dir in filter(Path.is_dir, self._base_output_dir.glob(\"tmp*\")):\n                shutil.rmtree(temp_dir)\n\n        # Must specify `ignore_cleanup_errors` to avoid fatal errors during cleanup on Windows\n        self._tempdir = (\n            tempfile.TemporaryDirectory(dir=self._base_output_dir, ignore_cleanup_errors=True) if ephemeral else None\n        )\n        self._output_dir = Path(self._tempdir.name) if self._tempdir else self._base_output_dir\n        self.__obj_class_name: Optional[str] = None\n\n        torch.serialization.add_safe_globals(safe_globals) if safe_globals else None\n\n    def load(self, name: str) -> T:\n        file_path = self._get_path(name)\n        try:\n            return torch.load(file_path)  # pyright: ignore [reportUnknownMemberType]\n        except FileNotFoundError as e:\n            raise ObjectNotFoundError(name) from e\n\n    def save(self, obj: T) -> str:\n        name = self._new_name()\n        file_path = self._get_path(name)\n        torch.save(obj, file_path)  # pyright: ignore [reportUnknownMemberType]\n        return name\n\n    def delete(self, name: str) -> None:\n        file_path = self._get_path(name)\n        file_path.unlink()\n\n    @property\n    def _obj_class_name(self) -> str:\n        if not self.__obj_class_name:\n            # `__orig_class__` is not available in the constructor for some technical, undoubtedly very pythonic reason\n            self.__obj_class_name = typing.get_args(self.__orig_class__)[0].__name__  # pyright: ignore [reportUnknownMemberType, reportAttributeAccessIssue]\n        return self.__obj_class_name\n","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/services/object_serializer/object_serializer_disk.py#L40-L76","documentation":"ObjectSerializerDisk.load(name) resolves `name` to a file under its on-disk base directory and deserializes it with torch.load. If the file is absent (FileNotFoundError), it re-raises as ObjectNotFoundError(name), so the message is the serialized-object name. This indicates the requested object was never saved, was deleted by cleanup/eviction, or the serializer's base directory differs from the one used to save it.","triggerScenarios":"Calling load(name) with a name that was never produced by save(); the file was deleted (disk cleanup, OS temp cleaning, deleted DB row while files remain pruned); a different base directory/temp dir configured between save and load (e.g. RAM-disk path changed across restarts).","commonSituations":"Restarting InvokeAI with a different configured temp/object-serializer directory; tmpfiles/systemd cleaning /tmp between runs; referencing a serialized object stored in an older session; concurrent cleanup deleting files mid-session.","solutions":["Guard with serializer.exists(name) (or os.path.exists on the path) before load, or catch ObjectNotFoundError and regenerate/re-save the object.","Check the object_serializer base directory config matches where the object was saved.","If the object is a transient intermediate (latents/images), re-run the generating operation instead of reloading.","Make temp directories persistent (outside /tmp or excluded from cleanup) if objects must survive restarts."],"exampleFix":"// before\nobj = serializer.load(name)\n// after\ntry:\n    obj = serializer.load(name)\nexcept ObjectNotFoundError:\n    obj = regenerate_and_save(serializer)","handlingStrategy":"try-catch","validationCode":"if not serializer.exists(name):\n    raise LookupError(f\"serialized object {name!r} missing on disk\")\nobj = serializer.load(name)","typeGuard":"import os\nfrom pathlib import Path\ndef object_on_disk(serializer, name: str) -> bool:\n    return Path(serializer._get_path(name)).exists() if hasattr(serializer, \"_get_path\") else False","tryCatchPattern":"try:\n    obj = serializer.load(name)\nexcept ObjectNotFoundError:\n    obj = regenerate_and_save(serializer)  # recompute the object","preventionTips":["Pin the object_serializer base directory in config so it survives restarts","Place temp/latent directories outside auto-cleaned /tmp paths","Re-save objects that can be regenerated instead of persisting references","Catch ObjectNotFoundError wherever serialized intermediates are consumed"],"tags":["invokeai","object-serializer","disk","file-not-found","torch"],"backgroundTag":"file-not-found","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}