{"record":{"id":"6ba296b4cefaed8a","repo":"RyanCodrai/turbovec","slug":"persisted-store-at-folder-was-saved-with-distanc","errorCode":null,"errorMessage":"persisted store at {folder} was saved with distance={recorded!r}, but this store was constructed with distance={self.distance.value!r}. Construct the store with the matching distance to load it.","messagePattern":"persisted store at (.+?) was saved with distance=(.+?), but this store was constructed with distance=(.+?)\\. Construct the store with the matching distance to load it\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"turbovec-python/python/turbovec/agno.py","lineNumber":1237,"sourceCode":"        )\n        if state.get(\"dimensions\") != self.dimensions:\n            raise ValueError(\n                f\"persisted dimensions={state.get('dimensions')} does not \"\n                f\"match this store's embedder dimensions={self.dimensions}\"\n            )\n        # Similarity mode of the persisted vectors. The construct-then-\n        # create() API shape means the store already has a mode when the\n        # load runs, so a *recorded* mode that conflicts with it is an\n        # error — silently adopting either side would surprise someone.\n        # A v1 side-car (written before the mode existed) records no\n        # mode but holds raw, unnormalized vectors: adopt\n        # Distance.max_inner_product — the scoring those stores were\n        # written under — and update `self.distance` so introspection\n        # reflects how the store actually scores.\n        recorded = state.get(\"distance\")\n        if recorded is not None:\n            if recorded != self.distance.value:\n                raise ValueError(\n                    f\"persisted store at {folder} was saved with \"\n                    f\"distance={recorded!r}, but this store was constructed \"\n                    f\"with distance={self.distance.value!r}. Construct the \"\n                    f\"store with the matching distance to load it.\"\n                )\n            distance = self.distance\n        else:\n            distance = Distance.max_inner_product\n\n        # This is the only in-place load among the four integrations (the\n        # others are classmethods returning a fresh object), so it is the\n        # only one that can leave a caller holding a half-loaded store.\n        # Everything below is therefore built into locals and committed in\n        # one block at the end: the validation after the rebuild still\n        # raises, and a store whose load raised is one this method never\n        # touched (#380).\n        index = IdMapIndex.load(str(index_file))\n        u64_to_doc = {int(h): d for h, d in state[\"u64_to_doc\"]}","sourceCodeStart":1219,"sourceCodeEnd":1255,"githubUrl":"https://github.com/RyanCodrai/turbovec/blob/ccab9f325e6ce2a270a87daf01ae4e443bcf2d49/turbovec-python/python/turbovec/agno.py#L1219-L1255","documentation":"Raised in TurboQuantVectorDb._load_from when the v2+ side-car records a distance/similarity mode that conflicts with the mode this store instance was constructed with. The construct-then-create() API means the load cannot silently adopt either mode — vectors written under one scoring mode are invalid under the other.","triggerScenarios":"Thrown at turbovec-python/python/turbovec/agno.py:1237 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-construct the store with the distance= value recorded in the side-car, then load again.","Inspect the saved docstore.json's `distance` field to learn the required constructor argument.","Catch the ValueError in tooling to report the exact mode mismatch instead of loading mismatched scoring."],"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"}