{"record":{"id":"c0f28a599166ba57","repo":"clockworklabs/SpacetimeDB","slug":"error-table-s-not-found-for-default-value-on-f","errorCode":null,"errorMessage":"ERROR: Table '%s' not found for default value on field '%s'\n","messagePattern":"ERROR: Table '(.+?)' not found for default value on field '(.+?)'\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/bindings-cpp/include/spacetimedb/internal/v9_builder.h","lineNumber":606,"sourceCode":"    index_def.accessor_name = index_name;  // User-provided index name for access\n    index_def.algorithm = algorithm;\n    \n    // Add to table's indexes\n    table->indexes.push_back(std::move(index_def));\n    \n    //fprintf(stdout, \"DEBUG: Successfully added multi-column index '%s' -> '%s' with %zu fields\\n\",\n    //        index_name.c_str(), generated_name.c_str(), field_indexes.size());\n}\n\n// Template implementation for AddColumnDefault\ntemplate<typename T>\nvoid V9Builder::AddColumnDefault(const std::string& table_name,\n                                 const std::string& field_name,\n                                 const std::vector<uint8_t>& serialized_value) {\n    // Find the existing table\n    RawTableDefV9* table = findTableByName(table_name);\n    if (!table) {\n        fprintf(stderr, \"ERROR: Table '%s' not found for default value on field '%s'\\n\",\n                table_name.c_str(), field_name.c_str());\n        return;\n    }\n    \n    // Get field descriptors to find the field index\n    SpacetimeDB::field_registrar<T>::register_fields();\n    auto& descriptor_map = SpacetimeDB::get_table_descriptors();\n    auto it = descriptor_map.find(&typeid(T));\n    if (it == descriptor_map.end()) {\n        fprintf(stderr, \"ERROR: No field descriptors found for table %s\\n\", table_name.c_str());\n        return;\n    }\n    \n    const auto& field_descs = it->second.fields;\n    uint16_t field_idx = 0;\n    bool field_found = false;\n    \n    // Find the field index","sourceCodeStart":588,"sourceCodeEnd":624,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/bindings-cpp/include/spacetimedb/internal/v9_builder.h#L588-L624","documentation":"V9Builder::AddColumnDefault resolves the table by name before attaching a serialized default value; when findTableByName finds no match, it prints this and returns, so the column default is silently dropped and the module publishes without it. Inserts that relied on the default will then require an explicit value (or fail), which is often how this is first noticed.","triggerScenarios":"The default-value annotation's table_name string doesn't exactly match a registered table (typo/casing/renamed table), or the default registration static object initializes before the table's registration in another translation unit.","commonSituations":"Table renames during schema evolution; default annotations kept in a central file that initializes before the tables; copy-paste between similar table names; mixing macro generations so the table is registered under a different builder.","solutions":["Match the table name string in the default annotation exactly to the table macro's name","Compile the table and its default annotation in the same translation unit to fix static-init ordering","Check for duplicate table name registrations that overwrote the original","After republishing, verify the column default shows in the table description"],"exampleFix":"// before\nST_TABLE(player, ...);\nST_COLUMN_DEFAULT(players, score, 0);   // wrong table name\n// after\nST_COLUMN_DEFAULT(player, score, 0);","handlingStrategy":"validation","validationCode":"#include <spacetimedb/internal/v9_builder.h>\nbool TableIsRegistered(const std::string& name) {\n    for (const auto& t : SpacetimeDB::Internal::GetV9Module().tables)\n        if (t.name == name) return true;\n    return false;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep default-value annotations next to the table macro they target","After table renames, sweep all annotations referencing the old name","Confirm defaults in the published schema — their absence is silent"],"tags":["spacetimedb","cpp","schema","column-default","table-not-found","v9-builder"],"backgroundTag":"schema-table-not-found","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}