{"record":{"id":"261e27df4cbfef8e","repo":"clockworklabs/SpacetimeDB","slug":"not-a-column-of-the-table","errorCode":null,"errorMessage":"not a column of the table","messagePattern":"not a column of the table","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/bindings-macro/src/table.rs","lineNumber":763,"sourceCode":"    let syn::Type::Path(type_path) = ty else {\n        return false;\n    };\n    type_path\n        .path\n        .segments\n        .last()\n        .is_some_and(|segment| segment.ident == \"String\")\n}\n\nfn try_find_column<'a, 'b, T: ?Sized>(cols: &'a [Column<'b>], name: &T) -> Option<&'a Column<'b>>\nwhere\n    Ident: PartialEq<T>,\n{\n    cols.iter().find(|col| col.ident == name)\n}\n\nfn find_column<'a, 'b>(cols: &'a [Column<'b>], name: &Ident) -> syn::Result<&'a Column<'b>> {\n    try_find_column(cols, name).ok_or_else(|| syn::Error::new(name.span(), \"not a column of the table\"))\n}\n\nenum ColumnAttr {\n    Unique(Span),\n    AutoInc(Span),\n    PrimaryKey(Span),\n    Index(IndexArg),\n    Default(syn::Expr, Span),\n}\n\nimpl ColumnAttr {\n    fn parse(attr: &syn::Attribute, field_ident: &Ident) -> syn::Result<Option<Self>> {\n        let Some(ident) = attr.path().get_ident() else {\n            return Ok(None);\n        };\n        Ok(if ident == sym::index {\n            let index = IndexArg::parse_index_attr(field_ident, attr)?;\n            Some(ColumnAttr::Index(index))","sourceCodeStart":745,"sourceCodeEnd":781,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/bindings-macro/src/table.rs#L745-L781","documentation":"While lowering a table, the macro resolves every column name referenced by index definitions and by the scheduled `at = ...` option against the struct's fields. `find_column` returns this error, with its span on the offending identifier, when no field ident matches. Field renames and copy-pasted index definitions between tables are the usual causes.","triggerScenarios":"`index = btree(a, b)` / `hash(...)` / `direct(...)` referencing an ident that is not a field of the struct; `scheduled(reducer, at = custom)` where `custom` names no field.","commonSituations":"Renaming struct fields during a refactor without updating index attributes; copying a table declaration and forgetting to update the index column list.","solutions":["Correct the referenced name so it matches an existing field ident exactly","If a field was renamed, update the index or `at = ...` attribute to the new name","If the reference was intentional, add the missing column to the struct"],"exampleFix":"// before\n#[spacetimedb::table(accessor = inventory, index = btree(item_id))]\nstruct Inventory {\n    id: u64,\n    item: String,\n}\n\n// after\n#[spacetimedb::table(accessor = inventory, index = btree(item))]\nstruct Inventory {\n    id: u64,\n    item: String,\n}","handlingStrategy":"validation","validationCode":"# list index declarations so you can cross-check each referenced ident against struct fields\ngrep -rEn 'index *= *(btree|hash|direct)' src/","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Rename fields and their index / `at = ...` references in the same commit","Keep index definitions directly on the struct they target","Use the error span — it points at the exact offending identifier"],"tags":["rust","proc-macro","spacetimedb","index","column","compile-time"],"backgroundTag":"unknown-column-reference","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}