{"record":{"id":"0ea5f8954d57410d","repo":"clockworklabs/SpacetimeDB","slug":"original-error-s","errorCode":null,"errorMessage":"Original error: %s\n\n","messagePattern":"Original error: (.+?)\n\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/bindings-cpp/src/internal/Module.cpp","lineNumber":287,"sourceCode":"    if (g_constraint_registration_error) {\n        getV10Builder().Clear();\n\n        std::string error_type_name = \"ERROR_CONSTRAINT_REGISTRATION_\" + g_constraint_registration_error_code;\n        for (char& c : error_type_name) {\n            if (!std::isalnum(c) && c != '_') {\n                c = '_';\n            }\n        }\n\n        RawTypeDefV10 error_type;\n        error_type.source_name.scope = {};\n        error_type.source_name.source_name = error_type_name;\n        error_type.ty = 999999;\n        error_type.custom_ordering = false;\n        getV10Builder().GetTypeDefs().push_back(error_type);\n\n        fprintf(stderr, \"\\n[CONSTRAINT REGISTRATION ERROR] Module cleared and replaced with error type: %s\\n\", error_type_name.c_str());\n        fprintf(stderr, \"Original error: %s\\n\\n\", g_constraint_registration_error_details.c_str());\n        fflush(stderr);\n        return;\n    }\n    \n    // Check if any errors occurred during type registration\n    auto& type_reg = getModuleTypeRegistration();\n    if (type_reg.hasError()) {\n        // Type registration detected an error - create a special error module\n        const std::string& error = type_reg.getErrorMessage();\n        \n        // Clear the module state to start fresh.\n        getV10Builder().Clear();\n        \n        // Create an error type name that embeds the error message and type structure\n        std::string error_type_name;\n        if (error.find(\"Recursive type reference\") != std::string::npos) {\n            // Extract the type name from the error message\n            size_t start = error.find(\"'\");","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/bindings-cpp/src/internal/Module.cpp#L269-L305","documentation":"Detail line of the '[CONSTRAINT REGISTRATION ERROR]' banner (error 668) that prints g_constraint_registration_error_details - the human-readable description recorded when SetConstraintRegistrationError was called. It typically names the table, field, or index involved, e.g. \"table='User' field='usr_id' was not found\".","triggerScenarios":"Always printed after error 668's banner; the details string comes directly from whichever V10Builder constraint check failed (field not found, table not registered, empty multi-index, default on primary key, and similar).","commonSituations":"Debugging a failed publish where the server only reports an ERROR_CONSTRAINT_REGISTRATION_* type; this stderr line is the only place the concrete table/field names appear.","solutions":["Parse the table='X' field='Y' (or index='Z') tokens in this line to locate the offending macro","Correct the macro: fix the field name, register the table first, or populate the index column list","Republish and verify the constraint error type is gone from the module description"],"exampleFix":"// before: details say field='usr_id' was not found\nFIELD_Unique(User, usr_id);\n\n// after\nFIELD_Unique(User, user_id);","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Extract the table='X' field='Y' names from this line to locate the bad macro","Fix names/ordering per the details string, then republish","Log module stderr during publish in CI so these detail lines are captured"],"tags":["spacetimedb","cpp","schema","constraints","diagnostics"],"backgroundTag":"schema-constraint-validation-failed","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}