{"record":{"id":"7bd85f872ac79b0d","repo":"clockworklabs/SpacetimeDB","slug":"local-module-schema-validation-failed","errorCode":null,"errorMessage":"Local module schema validation failed","messagePattern":"Local module schema validation failed","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/schema_extract.rs","lineNumber":172,"sourceCode":"                    ensure!(status.success(), \"Local module schema inspection failed\");\n                    Ok(())\n                }) => result.unwrap_or_else(|_| Err(anyhow::anyhow!(\"Local module schema inspection timed out\"))),\n            };\n            if result.is_err() {\n                // Queue termination, then retain ownership through positive reaping.\n                let _ = child.start_kill();\n                let status = child\n                    .wait()\n                    .await\n                    .context(\"Cannot reap failed local module inspector\")?;\n                observation.reaped(status);\n            }\n            result?;\n            // Neither parser nor validation diagnostics may echo schema literals.\n            let SerdeWrapper::<RawModuleDef>(raw) = serde_json::from_slice(&output)\n                .map_err(|_| anyhow::anyhow!(\"Local module inspector returned invalid schema data\"))?;\n            let schema =\n                ModuleDef::try_from(raw).map_err(|_| anyhow::anyhow!(\"Local module schema validation failed\"))?;\n            Ok(schema)\n        }\n        .await;\n        let _ = send.send(result);\n    });\n    (&mut recv).await.context(\"Local module inspection owner failed\")?\n}\n\n#[cfg(test)]\nmod tests;\n","sourceCodeStart":154,"sourceCodeEnd":183,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/eddf9f5014579a50d4b67630e28b6e15cad9c4af/crates/cli/src/schema_extract.rs#L154-L183","documentation":"Once the inspector's JSON parses into RawModuleDef, ModuleDef::try_from performs semantic validation (table/index/reducer definitions). If conversion fails, the schema is structurally valid JSON but semantically invalid, and this error is returned — intentionally without echoing schema literals.","triggerScenarios":"The inspector produced a RawModuleDef that fails ModuleDef validation — e.g. duplicate table/column names, invalid identifiers, constraint or index definitions that violate SpacetimeDB rules — typically from a module written with constructs the extractor mis-translates.","commonSituations":"Modules using newly added language features with an older CLI; duplicated or conflicting table aliases; invalid column types or constraints in the module source.","solutions":["Update the SpacetimeDB CLI and module dependencies (spacetimedb-sdk/lib) to matching versions.","Review the module for duplicate table/index/reducer names or invalid identifiers and constraints.","Try publishing the module instead — publish errors may pinpoint the invalid definition.","Simplify the offending definition to isolate which declaration fails validation."],"exampleFix":"// before\n#[spacetimedb::table(name = users)]\nstruct Users; // name/struct mismatch after rename\n// after\n#[spacetimedb::table(name = users)]\nstruct User;","handlingStrategy":"validation","validationCode":"// offline lint: ensure unique table names and valid identifiers before extraction\nlet names: Vec<_> = tables.iter().map(|t| &t.name).collect();\nassert_unique(&names, \"duplicate table names\");","typeGuard":null,"tryCatchPattern":"let schema = ModuleDef::try_from(raw).map_err(|e| anyhow!(\"Module defines an invalid schema: {e}\"))?;","preventionTips":["Keep module lib and CLI versions aligned","Avoid duplicate/conflicting table, index, and reducer names","Validate constraints and identifiers against SpacetimeDB rules early","Use `spacetime publish` errors to pinpoint invalid definitions"],"tags":["schema","validation","module","rust"],"backgroundTag":"schema-validation-failed","analyzedSha":"eddf9f5014579a50d4b67630e28b6e15cad9c4af","analyzedAt":"2026-09-20T12:15:59.611Z","contentChangedAt":"2026-09-20T12:15:59.611Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}