clockworklabs/SpacetimeDB · error
Failed to generate table due to validation errors
Error message
Failed to generate table due to validation errors
What it means
Panic in SpacetimeDB's Unreal Engine C++ binding generator (`spacetime generate --lang cpp` etc.). When generating code for each module view, the generator builds a `TableSchema::from_view_def_for_codegen(...)` and calls `.validated()`; if the view's schema collects any validation errors, `expect` panics and aborts codegen. It means the module's view definition itself is structurally invalid from the schema validator's perspective.
Source
Thrown at crates/codegen/src/unrealcpp.rs:1152
let schema = TableSchema::from_module_def(module, table, (), 0.into())
.validated()
.expect("table schema should validate");
let table_cpp_content = generate_table_cpp(self.module_prefix, module, table, self.module_name, &schema);
let table_cpp_filename = format!(
"Source/{}/Private/ModuleBindings/Tables/{}Table.g.cpp",
self.module_name,
format_args!("{module_prefix}{}", table.name.deref().to_case(Case::Pascal))
);
files.push(OutputFile {
filename: table_cpp_filename,
code: table_cpp_content,
});
}
for view in module.views() {
let tbl = TableDef::from(view.clone());
let schema = TableSchema::from_view_def_for_codegen(module, view)
.validated()
.expect("Failed to generate table due to validation errors");
let view_cpp_content = generate_table_cpp(self.module_prefix, module, &tbl, self.module_name, &schema);
let view_cpp_filename = format!(
"Source/{}/Private/ModuleBindings/Tables/{}Table.g.cpp",
self.module_name,
format_args!("{module_prefix}{}", view.name.deref().to_case(Case::Pascal))
);
files.push(OutputFile {
filename: view_cpp_filename,
code: view_cpp_content,
});
}
files
}
}
// Helper function to generate table .cpp implementation files
fn generate_table_cpp(View on GitHub (pinned to 6dee26c6ef)
Solutions
- Re-run `spacetime build` / validation on the module to surface the underlying validation error messages before codegen (the panic message itself hides the error list).
- Inspect recently added views in the module and remove or fix the one that fails validation (often an unsupported type or bad projection).
- Check SpacetimeDB release notes for schema-validation changes and update the module SDK (`spacetime` CLI + `spacetimedb-std`) to matching versions.
- If the view is optional for your game client, delete it from the module and regenerate to confirm it is the culprit, then re-add incrementally.
Example fix
// module (before): view with a type Unreal codegen cannot validate
view BadView { projection: SomeUnsupportedType }
// module (after): project a supported scalar/product type
view BadView { projection: String } Defensive patterns
Strategy: validation
Validate before calling
// Before codegen, validate every table/view schema the same way codegen does
use spacetimedb_schema::table::TableSchema;
for view in module.views() {
if let Err(errors) = TableSchema::from_view_def_for_codegen(module, view).validated() { /* fix errors before generate */ }
} Prevention
- Run `spacetime build` and fix all schema-validation errors before `spacetime generate`.
- Keep the CLI and module SDK (`spacetimedb-std`) on the same release line.
- Add new views incrementally and regenerate after each addition so failures localize.
When it happens
Trigger: Running codegen for Unreal C++ bindings against a module whose `view` definition fails `TableSchema` validation — e.g. a view projecting unsupported types, mismatched column/index definitions, or a view referencing elements the schema validator rejects. The sibling loop over tables uses the same pattern, so a bad table can also surface here when `TableDef::from(view)` is built.
Common situations: Upgrading SpacetimeDB CLI or module SDK versions where view validation rules tightened; hand-editing a `.satellite`/module schema; adding a new view with exotic types (e.g. certain sum types or nested structures) that Unreal codegen cannot map; mixing old generated bindings with a new module.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- table schema should validate for query builder codegen
- view schema should validate for query builder codegen
- table should exist in the database for AddConstraint
- expected ModuleDef to contain key, but it does not
- `table_id` must not be `TableId::SENTINEL` in `{row_level_se
AI-assisted analysis of clockworklabs/SpacetimeDB@6dee26c6ef (2026-08-20).
Data as JSON: /api/errors/b89aa6ed87426831.
Report an issue: GitHub.