{"record":{"id":"1fea4a40a3db790e","repo":"clockworklabs/SpacetimeDB","slug":"unexpected-error-from-datastore-index-scan-point","errorCode":null,"errorMessage":"unexpected error from `datastore_index_scan_point_bsatn`: {e}","messagePattern":"unexpected error from `datastore_index_scan_point_bsatn`: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/bindings/src/table.rs","lineNumber":455,"sourceCode":"    let point = IterBuf::serialize(col_val).unwrap();\n\n    let iter = datastore_index_scan_point_bsatn(index_id, &point);\n    let mut iter = TableIter::new_with_buf(iter, point);\n\n    // We will always find either 0 or 1 rows here due to the unique constraint.\n    let row = iter.next();\n    assert!(\n        iter.is_exhausted(),\n        \"`datastore_index_scan_point_bsatn` on unique field cannot return >1 rows\"\n    );\n    row\n}\n\n/// See `sys::datastore_index_scan_point_bsatn`.\n/// Panics when the aforementioned errors.\nfn datastore_index_scan_point_bsatn(index_id: IndexId, point: &[u8]) -> sys::RowIter {\n    sys::datastore_index_scan_point_bsatn(index_id, point)\n        .unwrap_or_else(|e| panic!(\"unexpected error from `datastore_index_scan_point_bsatn`: {e}\"))\n}\n\n/// A read-only handle to a unique (single-column) index.\n///\n/// This is the read-only version of [`UniqueColumn`].\n/// It mirrors [`UniqueColumn`] but only exposes read APIs.\n/// It cannot insert or delete rows.\n/// It is used by `{table}__ViewHandle` to keep view code read-only at compile time.\n///\n/// Note, the `Tbl` generic is the read-write table handle `{table}__TableHandle`.\n/// This is because read-only indexes still need [`Table`] metadata.\n/// The view handle itself deliberately does not implement `Table`.\npub struct UniqueColumnReadOnly<Tbl, ColType, Col> {\n    _marker: PhantomData<(Tbl, ColType, Col)>,\n}\n\nimpl<Tbl: Table, Col: Index + Column<Table = Tbl>> UniqueColumnReadOnly<Tbl, Col::ColType, Col> {\n    #[doc(hidden)]","sourceCodeStart":437,"sourceCodeEnd":473,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/bindings/src/table.rs#L437-L473","documentation":"Internal wrapper used by find/filter helpers on unique columns; it panics when the datastore_index_scan_point_bsatn syscall returns an error. Errors mean the BSATN-encoded point failed to decode as the index's key type or the index id is invalid - i.e. compiled-in metadata disagrees with the deployed database schema.","triggerScenarios":"Searching a unique column (ctx.db.table().col().find(v)) after the module's column type or index definition changed without a matching rebuild; crate/host version mismatch producing incompatible index ids.","commonSituations":"Schema migration (column type widened/renamed) with stale generated code; deploying to a server of a different version than the toolchain used to build the module.","solutions":["Regenerate bindings and rebuild/redeploy so index ids and key types match the deployed schema.","Confirm the queried column is declared #[unique] or indexed as expected in the current module source.","Align spacetimedb crate and host versions; report an issue with the errno if it persists."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify the queried column is #[unique]/#[index] in current module source.","Regenerate bindings after type changes to indexed columns.","Match crate and host versions to keep index ids and key encodings consistent."],"tags":["rust","module","index-scan","query","schema-mismatch"],"backgroundTag":"index-scan-failed","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}