{"record":{"id":"42bb43b98cb7a80b","repo":"clockworklabs/SpacetimeDB","slug":"must-specify-view-accessor-e-g-spacetimedb-v","errorCode":null,"errorMessage":"must specify view accessor, e.g. `#[spacetimedb::view(accessor = {view})]","messagePattern":"must specify view accessor, e\\.g\\. `#\\[spacetimedb::view\\(accessor = (.+?)\\)\\]","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/bindings-macro/src/view.rs","lineNumber":83,"sourceCode":"                sym::public => {\n                    check_duplicate_msg(&public, &meta, \"`public` already specified\")?;\n                    public = Some(());\n                }\n                sym::accessor => {\n                    check_duplicate_msg(&accessor, &meta, \"`accessor` already specified\")?;\n                    accessor = Some(meta.value()?.parse()?);\n                }\n                sym::primary_key => {\n                    check_duplicate_msg(&primary_key, &meta, \"`primary_key` already specified\")?;\n                    primary_key = Some(ViewPrimaryKeyArg::parse(meta.value()?)?);\n                }\n            });\n            Ok(())\n        })\n        .parse2(input)?;\n        let accessor = accessor.ok_or_else(|| {\n            let view = func_ident.to_string().to_snake_case();\n            syn::Error::new(\n                Span::call_site(),\n                format_args!(\"must specify view accessor, e.g. `#[spacetimedb::view(accessor = {view})]\"),\n            )\n        })?;\n        let () = public\n            .ok_or_else(|| syn::Error::new(Span::call_site(), \"views must be `public`, e.g. `#[view(public)]`\"))?;\n        Ok(Self {\n            name,\n            primary_key,\n            public: true,\n            accessor,\n        })\n    }\n}\n\n/// If `ty` is `impl Query<T>`, returns `Some(T)`. Otherwise `None`.\nfn extract_impl_query_inner(ty: &syn::Type) -> Option<&syn::Type> {\n    if let syn::Type::ImplTrait(impl_trait) = ty {","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/bindings-macro/src/view.rs#L65-L101","documentation":"SpacetimeDB views must declare `accessor = ...`, which names the generated view accessor used by module code and clients. When the attribute parses without an accessor, the macro errors at call site and suggests the snake_case of the view function's ident. Like tables in 2.x, views migrated from older versions need this argument added.","triggerScenarios":"`#[spacetimedb::view]` (or with other args such as `name = ...` only) on a fn without `accessor = ...`.","commonSituations":"Writing a first view following older documentation; migrating views from a version where the accessor was implicit.","solutions":["Add the accessor: `#[spacetimedb::view(accessor = top_scores)]` using the snake_case of the fn name","Add `public` while you are there — it is also mandatory","Regenerate bindings after the change so clients pick up the view accessor"],"exampleFix":"// before\n#[spacetimedb::view]\nfn top_scores() -> impl Query<Score> { ... }\n\n// after\n#[spacetimedb::view(accessor = top_scores, public)]\nfn top_scores() -> impl Query<Score> { ... }","handlingStrategy":"validation","validationCode":"# list view attributes lacking an accessor\ngrep -rn 'spacetimedb::view' src/ | grep -v accessor || echo OK","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always declare views with both `accessor = <snake_case>` and `public`","Copy view declarations from current docs","After adding a view, regenerate bindings so clients see the accessor"],"tags":["rust","proc-macro","spacetimedb","view","compile-time"],"backgroundTag":"missing-required-attribute","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}