{"record":{"id":"7a158609e6943f45","repo":"RyanCodrai/turbovec","slug":"turboquantvectordb-has-no-index-to-save-call-cre","errorCode":null,"errorMessage":"TurboQuantVectorDb has no index to save — call create() first.","messagePattern":"TurboQuantVectorDb has no index to save — call create\\(\\) first\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"turbovec-python/python/turbovec/agno.py","lineNumber":1175,"sourceCode":"    def save(self, folder_path: Optional[str] = None) -> None:\n        \"\"\"Persist the quantized index plus a JSON side-car to disk. Pass\n        ``folder_path`` to override the constructor's ``path=``.\n\n        Writes two files under ``folder_path``:\n          - ``index.tvim`` — the :class:`IdMapIndex` payload.\n          - ``docstore.json`` — JSON-encoded document text, metadata, and\n            id maps. Side-car carries a ``schema_version`` field; loaders\n            reject unknown versions rather than silently misinterpreting\n            bytes.\n        \"\"\"\n        path = folder_path if folder_path is not None else self.path\n        if path is None:\n            raise ValueError(\n                \"No path to save to. Pass `folder_path=` here or set \"\n                \"`path=` on the constructor.\"\n            )\n        if self._index is None:\n            raise RuntimeError(\n                \"TurboQuantVectorDb has no index to save — call create() first.\"\n            )\n        folder = Path(path)\n        folder.mkdir(parents=True, exist_ok=True)\n        # Serializes with writers: snapshotting the maps and the index\n        # concurrently with a write would persist a torn store to disk.\n        # Reads may proceed while a save runs.\n        with self._write_lock:\n            payload = {\n                \"schema_version\": _DOCSTORE_SCHEMA_VERSION,\n                # Round-trip int handles via list-of-pairs (JSON keys must be\n                # strings, but our handles are ints).\n                \"u64_to_doc\": [[h, d] for h, d in self._u64_to_doc.items()],\n                \"next_u64\": self._next_u64,\n                \"bit_width\": self.bit_width,\n                \"dimensions\": self.dimensions,\n                # Recorded so a later create()/load restores the mode the\n                # vectors were written under (v2+).","sourceCodeStart":1157,"sourceCodeEnd":1193,"githubUrl":"https://github.com/RyanCodrai/turbovec/blob/ccab9f325e6ce2a270a87daf01ae4e443bcf2d49/turbovec-python/python/turbovec/agno.py#L1157-L1193","documentation":"Raised in TurboQuantVectorDb.save when self._index is None — i.e. create() was never called and no vectors have been added, so there is no quantized index payload to persist. It prevents writing an empty/broken store that a later load would fail on.","triggerScenarios":"Thrown at turbovec-python/python/turbovec/agno.py:1175 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Call create() (which builds/locks the index) before save().","Ensure at least one insert/upsert has run so the index exists, then save.","Guard persistence code with `if store._index is not None` or catch the RuntimeError to skip saving empty stores."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ccab9f325e6ce2a270a87daf01ae4e443bcf2d49","analyzedAt":"2026-09-06T08:39:18.516Z","contentChangedAt":"2026-09-06T08:39:18.516Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}