{"record":{"id":"9bab48025a2506cd","repo":"clockworklabs/SpacetimeDB","slug":"local-module-inspector-returned-invalid-schema-data","errorCode":null,"errorMessage":"Local module inspector returned invalid schema data","messagePattern":"Local module inspector returned invalid schema data","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/schema_extract.rs","lineNumber":170,"sourceCode":"                    let status = child.wait().await.context(\"Cannot reap local module inspector\")?;\n                    observation.reaped(status);\n                    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":152,"sourceCodeEnd":183,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/eddf9f5014579a50d4b67630e28b6e15cad9c4af/crates/cli/src/schema_extract.rs#L152-L183","documentation":"After the inspector child exits successfully, its raw JSON stdout is deserialized into SerdeWrapper<RawModuleDef>. If serde_json::from_slice fails, the output is not the expected schema JSON (and per the code comment, diagnostics are deliberately suppressed so schema literals never echo), yielding this generic error.","triggerScenarios":"The inspector process wrote malformed, empty, or non-JSON output to stdout despite exiting with status 0 — e.g. version mismatch between CLI and extractor binary, corrupted output truncation, or stray prints on stdout.","commonSituations":"Mismatched extractor_binary/CLI versions after an upgrade; extractor binary replaced or corrupted; module host (JS/WASM) printing debug logs to stdout instead of stderr.","solutions":["Reinstall/refresh the extractor binary so CLI and inspector versions match (rerun publish or update the CLI).","Ensure the module/build does not print anything to stdout during inspection (use stderr for logs).","Retry to rule out truncated I/O.","Capture the extractor's exit status and stderr for debugging if it persists."],"exampleFix":"// before\nconsole.log(\"loading module...\"); // pollutes stdout\n// after\nconsole.error(\"loading module...\");","handlingStrategy":"validation","validationCode":"if (!/^\\s*\\{/.test(inspectorStdout)) throw new Error('Inspector did not output JSON; check for stdout logging in module host');","typeGuard":null,"tryCatchPattern":"let raw: RawModuleDef; match serde_json::from_slice(&out) { Ok(v) => raw = v.0, Err(_) => bail!(\"inspect stdout was not schema JSON; check extractor version\") }","preventionTips":["Never print debug logs to stdout in module host code","Keep CLI and extractor binary versions in sync","Reinstall the extractor binary after upgrading SpacetimeDB"],"tags":["json","serialization","subprocess","rust"],"backgroundTag":"json-parse-error","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"}