clockworklabs/SpacetimeDB · error
source_name should be provided in V10, accessor_names inside
Error message
source_name should be provided in V10, accessor_names inside module
What it means
In schema-def validation for V10+, `RawIndexDefV10.source_name` is an Option, but the v10 format requires it, so `validate_index_def_v10` unwraps with this expect. The field is populated by the spacetimedb macro codegen; hitting the panic means the RawIndexDefV10 was hand-constructed without source_name, or produced by mismatched macro/schema crate versions.
Source
Thrown at crates/schema/src/def/validate/v9.rs:1234
namespace: NamespacePath::root(),
name: name.clone(),
accessor_name: codegen_name,
source_name: name,
algorithm,
})
}
/// Validates an index definition for V10 and later versions
pub(crate) fn validate_index_def_v10(&mut self, index: RawIndexDefV10) -> Result<IndexDef> {
let RawIndexDefV10 {
source_name,
algorithm: algorithm_raw,
accessor_name,
} = index;
//source_name will be used as alias, hence we need to add it to the global namespace as
//well.
let source_name = source_name.expect("source_name should be provided in V10, accessor_names inside module");
let source_name = self.add_to_global_namespace(source_name.clone())?;
let name = if self.module_validator.explicit_names.indexes.get(&source_name).is_some() {
self.module_validator.resolve_index_ident(source_name.clone())?
} else {
identifier(generate_index_name(
&self.table_ident,
self.product_type,
&algorithm_raw,
))?
};
let name = if *name.as_raw() != source_name {
self.add_to_global_namespace(name.as_raw().clone())?
} else {
name.as_raw().clone()
};
View on GitHub (pinned to 524b4487d9)
Solutions
- Set source_name (Some(identifier)) when constructing RawIndexDefV10 manually — it becomes the index's alias in the global namespace.
- Align spacetimedb crate versions so macro codegen and schema validator agree (check cargo tree for mixed versions).
- Prefer deriving index defs via #[spacetimedb::table(index(...))] instead of hand-building raw defs.
Example fix
// before
let def = RawIndexDefV10 { source_name: None, algorithm, accessor_name };
// after: V10 defs require the source name
let def = RawIndexDefV10 { source_name: Some(identifier("players_name_idx")?), algorithm, accessor_name }; Defensive patterns
Strategy: validation
Validate before calling
let def = RawIndexDefV10 { source_name: Some(index_name.clone()), algorithm, accessor_name };
assert!(def.source_name.is_some(), "V10 index defs require source_name"); Prevention
- Pin consistent versions of all spacetimedb crates in the workspace.
- Let macros generate index defs; don't hand-assemble raw def structs.
- Add a smoke test validating a generated module def after dependency upgrades.
When it happens
Trigger: Manually building `RawIndexDefV10 { source_name: None, .. }` and validating it; or mixing an older bindings-macro crate that emits V10 defs without source_name with a newer schema crate that requires it.
Common situations: Custom build pipelines that synthesize index defs; dependency version skew among spacetimedb crates (Cargo tree -p spacetimedb-bindings-macro / spacetimedb-schema); forked codegen missing the field.
Related errors
- Index '${idx.sourceName ?? '<unknown>'}' on table '${tableDe
- Index '${indexLabel}' on table '${tableLabel}' must define a
- never types are not yet supported in C# output
- Unknown index algorithm {:?}
- a direct index must be paired with a `#[unique] constraint
AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16).
Data as JSON: /api/errors/359f930b8a292d66.
Report an issue: GitHub.