{"record":{"id":"9bdf6b3875b202c7","repo":"clockworklabs/SpacetimeDB","slug":"must-specify-table-accessor-e-g-spacetimedb","errorCode":null,"errorMessage":"must specify table accessor, e.g. `#[spacetimedb::table(accessor = {table})]","messagePattern":"must specify table accessor, e\\.g\\. `#\\[spacetimedb::table\\(accessor = (.+?)\\)\\]","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/bindings-macro/src/table.rs","lineNumber":178,"sourceCode":"                // In this case, they probably intended to change `name =` to `accessor =`,\n                // but were misled into keeping `name =` and changing the name from an ident into a lit string.\n                // Detect that and offer a diagnostic with a simple fix.\n                // Unfortunately, we can't hook in to rustc's system for providing quick fixes in compiler errors,\n                // until [this ancient issue](https://github.com/rust-lang/rust/issues/54140) gets stabilized.\n                let name_str_value = name_str.value();\n                syn::Error::new_spanned(\n                    name_str,\n                    format_args!(\n                        \"Expected an `accessor` in table definition, but got only a `name`.\nDid you mean to specify `accessor` instead?\n`accessor` is required, but `name` is optional.\n\nIf you're migrating from SpacetimeDB 1.*, replace `name = {name_str_value:?}` with `accessor = {name_str_value}`\",\n                    ),\n                )\n            } else {\n                let table = struct_ident.to_string().to_snake_case();\n                syn::Error::new(\n                    Span::call_site(),\n                    format_args!(\"must specify table accessor, e.g. `#[spacetimedb::table(accessor = {table})]\"),\n                )\n            }\n        })?;\n        Ok(TableArgs {\n            access,\n            scheduled,\n            accessor,\n            indices,\n            name,\n            event,\n        })\n    }\n}\n\nimpl ScheduledArg {\n    fn parse_meta(meta: ParseNestedMeta) -> syn::Result<Self> {","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/bindings-macro/src/table.rs#L160-L196","documentation":"Since SpacetimeDB 2.x, `#[spacetimedb::table]` requires an `accessor` argument, which names the generated accessor/row type used by module code and client bindings; `name` is optional and only sets the on-chain table name. When the attribute list contains neither an accessor nor a legacy `name`, the macro errors at call site and suggests the snake_case form of the struct ident. (Supplying only a 1.x-style `name = \"...\"` produces the sibling migration-hint error instead.)","triggerScenarios":"`#[spacetimedb::table]` with an empty argument list; writing a new table after a 1.x to 2.x upgrade without adding `accessor = ...`.","commonSituations":"Upgrading a module from SpacetimeDB 1.x to 2.x following old tutorials or docs; creating a first table without using the 2.x project template.","solutions":["Add the accessor argument: `#[spacetimedb::table(accessor = player)]` using the snake_case of the struct name","When migrating from 1.x `name = \"player\"`, replace it with `accessor = player` (keep `name` only if you also need a distinct on-chain table name)","Regenerate client bindings after the change so the accessor types line up"],"exampleFix":"// before\n#[spacetimedb::table]\nstruct Player {\n    id: u64,\n}\n\n// after\n#[spacetimedb::table(accessor = player)]\nstruct Player {\n    id: u64,\n}","handlingStrategy":"validation","validationCode":"# list table attributes lacking an accessor before building\ngrep -rn 'spacetimedb::table' src/ | grep -v accessor || echo OK","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write `accessor = <snake_case_name>` by habit when creating every table","After a SpacetimeDB version upgrade, grep for `spacetimedb::table(name =` and migrate each hit","Copy table declarations from current docs or the project template, not from old projects"],"tags":["rust","proc-macro","spacetimedb","table","migration","compile-time"],"backgroundTag":"missing-required-attribute","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}