{"record":{"id":"b897b646667d1b64","repo":"clockworklabs/SpacetimeDB","slug":"default-export-is-not-a-schema-object","errorCode":null,"errorMessage":"default export is not a Schema object","messagePattern":"default export is not a Schema object","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/core/src/host/v8/syscall/mod.rs","lineNumber":146,"sourceCode":") -> Result<Option<HookFunctions<'scope>>, ErrorOrException<ExceptionThrown>> {\n    // We only set RECV_SLOT_INDEX in set_registered_hooks, which is only called in\n    // the v2 code path. Set it to undefined ahead of time so it's not a garbage value.\n    scope\n        .get_current_context()\n        .set_embedder_data(hooks::RECV_SLOT_INDEX, v8::undefined(scope).into());\n    if let Some(hooks) = get_registered_hooks(scope) {\n        return Ok(Some(hooks));\n    }\n\n    let default = super::str_from_ident!(default).string(scope);\n    let default_export = exports_obj\n        .get(scope, default.into())\n        .ok_or_else(exception_already_thrown)?;\n    if default_export.is_null_or_undefined() {\n        return Ok(None);\n    }\n    let hooks = v2::get_hooks_from_default_export(scope, default_export, exports_obj)?\n        .ok_or_else(|| anyhow::anyhow!(\"default export is not a Schema object\"))?;\n    Ok(Some(hooks))\n}\n\n/// Process the thrown exception value into an `ExecutionError`.\npub(super) fn process_thrown_exception(\n    scope: &mut PinScope<'_, '_>,\n    hooks: &HookFunctions<'_>,\n    exc: Local<'_, v8::Value>,\n) -> ExcResult<Option<ExecutionError>> {\n    match hooks.abi {\n        AbiVersion::V1 => Ok(None),\n        AbiVersion::V2 => v2::process_thrown_exception(scope, hooks, exc),\n    }\n}\n","sourceCodeStart":128,"sourceCodeEnd":161,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/eddf9f5014579a50d4b67630e28b6e15cad9c4af/crates/core/src/host/v8/syscall/mod.rs#L128-L161","documentation":"For v2-ABI JS modules, the default export must be a Schema object produced by the SDK's schema DSL; v2::get_hooks_from_default_export returning None means the export exists but its shape is not recognized, so the host cannot extract module hooks from it.","triggerScenarios":"Default-exporting a plain object, arbitrary class instance, or v1-style definition where v2 expects a Schema object; an SDK major-version change altering the expected export shape; partial migration of a module to the v2 ABI.","commonSituations":"Upgrading the SDK without migrating the module entry point; mixing v1 and v2 patterns in one module; hand-crafted default exports.","solutions":["Build the default export with the current SDK's Schema/module-definition API.","Re-scaffold from the current quickstart template and diff your entry file.","Ensure the whole module targets one ABI version consistently.","Match the module SDK version to the host ABI."],"exampleFix":"// before (v2 host expects a Schema object)\nexport default { tables: {}, reducers: {} }; // plain object -> 'default export is not a Schema object'\n\n// after\nimport { Schema } from '<current-sdk>';\nexport default new Schema(/* ... */); // constructed via the SDK's schema DSL","handlingStrategy":"try-catch","validationCode":"const mod = await import('./dist/module.js');\nif (!mod.default || !(mod.default instanceof Schema)) {\n  throw new Error('default export must be a Schema object');\n}","typeGuard":"function isSchemaExport(x: unknown): x is Schema {\n  return x instanceof Schema;\n}","tryCatchPattern":"Catch module-build/publish errors; when the message mentions the default export, fail fast with a pointer to the SDK migration guide for the v2 ABI.","preventionTips":["Lock the SDK version in package.json and run its codemods on major upgrades.","Assert the default export's type in a unit test shipped with the module.","Do not mix v1 and v2 module styles."],"tags":["javascript","schema","default-export","v2-abi","v8"],"backgroundTag":"invalid-default-export","analyzedSha":"eddf9f5014579a50d4b67630e28b6e15cad9c4af","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}