{"record":{"id":"9d3f03a5b443cf95","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":"exception","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/6dee26c6efc2856793e12b148a59742964f5d783/crates/bindings-macro/src/view.rs#L65-L101","documentation":"Compile-time error from the #[spacetimedb::view] procedural macro. A view must declare which table accessor it projects over via the accessor = <expr> key-value argument (e.g. accessor = person, referring to the accessor generated by #[spacetimedb::table]). If attribute parsing finishes without an accessor key, the macro derives a snake_case suggestion from the view function's identifier and raises this error at the attribute's call site.","triggerScenarios":"Applying #[spacetimedb::view] or #[spacetimedb::view(...)] without an accessor = ... key-value pair; misspelling the key (accessors =, table =) so the parser skips it and accessor stays None.","commonSituations":"Writing a new view and forgetting the accessor; renaming a table's accessor without updating the view attribute; moving to a bindings version where accessor became mandatory.","solutions":["Add accessor = <accessor-name> to the attribute, e.g. #[spacetimedb::view(public, accessor = person)].","If unsure of the name, use the snake_case suggestion the error message already prints from your view function's identifier.","Check the key spelling - unknown keys are silently skipped by the parser, so a typo produces this error even though an argument looks present."],"exampleFix":"// before\n#[spacetimedb::view(public)]\nfn adults() -> impl Query<Person> { /* ... */ }\n\n// after\n#[spacetimedb::view(public, accessor = person)]\nfn adults() -> impl Query<Person> { /* ... */ }","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always write views with both required arguments: public and accessor = ...","Copy the attribute list from an existing working view in the project.","Remember unknown/misspelled attribute keys are ignored by the parser - double-check spelling when this error appears despite an argument being present."],"tags":["rust","proc-macro","spacetimedb","view","compile-time"],"backgroundTag":"missing-required-attribute","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}