{"record":{"id":"743d1b4deec5e86f","repo":"clockworklabs/SpacetimeDB","slug":"unique-unexpected-error-from-datastore-delete-by","errorCode":null,"errorMessage":"unique: unexpected error from datastore_delete_by_index_scan_point_bsatn: {e}","messagePattern":"unique: unexpected error from datastore_delete_by_index_scan_point_bsatn: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/bindings/src/table.rs","lineNumber":372,"sourceCode":"    {\n        find::<Tbl, Col>(col_val.borrow())\n    }\n\n    /// Deletes the row where the value in the unique column matches the supplied `col_val`,\n    /// if any such row is present in the database state.\n    ///\n    /// Returns `true` if a row with the specified `col_val` was previously present and has been deleted,\n    /// or `false` if no such row was present.\n    #[inline]\n    pub fn delete(&self, col_val: impl Borrow<Col::ColType>) -> bool {\n        self._delete(col_val.borrow()).0\n    }\n\n    fn _delete(&self, col_val: &Col::ColType) -> (bool, IterBuf) {\n        let index_id = Col::index_id();\n        let point = IterBuf::serialize(col_val).unwrap();\n        let n_del = sys::datastore_delete_by_index_scan_point_bsatn(index_id, &point).unwrap_or_else(|e| {\n            panic!(\"unique: unexpected error from datastore_delete_by_index_scan_point_bsatn: {e}\")\n        });\n\n        (n_del > 0, point)\n    }\n\n    /// Deletes the row where the value in the unique column matches that in the corresponding field of `new_row`, and\n    /// then inserts the `new_row`.\n    ///\n    /// Returns the new row as actually inserted, with computed values substituted for any auto-inc placeholders.\n    ///\n    /// This method can only be called on primary key columns, not any unique column.\n    /// This prevents confusion regarding what constitutes a row update vs. a delete+insert.\n    /// To perform this operation for a non-primary unique column, call\n    /// `.delete(key)` followed by `.insert(row)`.\n    ///\n    /// # Panics\n    /// Panics if no row was previously present with the matching value in the unique column,\n    /// or if either the delete or the insertion would violate a constraint.","sourceCodeStart":354,"sourceCodeEnd":390,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/bindings/src/table.rs#L354-L390","documentation":"UniqueColumn::delete deletes the row whose unique-column value matches, returning false when no such row exists (normal miss, not an error). The panic fires only when the underlying datastore_delete_by_index_scan_point_bsatn syscall itself returns an error - e.g. the BSATN-encoded key point fails to decode against the index's key type or the index id is invalid for the deployed schema.","triggerScenarios":"Module/host schema skew: bindings compiled against an index definition that differs from the deployed one; a column type change (e.g. u32 to u64) so the serialized point no longer matches the index key's AlgebraicType; stale index ids after republishing without a matching rebuild.","commonSituations":"Redeploying a module with column type changes while the crate and host versions drift; using hand-modified generated table code with wrong index ids.","solutions":["Verify the column is actually #[unique] (this API is for unique columns) and that bindings are freshly generated.","Clean rebuild and republish (cargo clean && spacetime publish) so index ids match the deployed schema.","Align the spacetimedb crate version with the host server version; if it still reproduces, file an issue with the errno."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Confirm the column is #[unique] before using its delete-by-value API.","Regenerate bindings and republish together after any schema change.","Keep spacetimedb crate and server versions aligned."],"tags":["rust","module","delete","unique-column","index"],"backgroundTag":"index-delete-failed","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}