{"record":{"id":"710b6f9990df8f0f","repo":"clockworklabs/SpacetimeDB","slug":"error-field-s-not-found-in-table-s-for-mult","errorCode":null,"errorMessage":"ERROR: Field '%s' not found in table '%s' for multi-column index\n","messagePattern":"ERROR: Field '(.+?)' not found in table '(.+?)' for multi-column index\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/bindings-cpp/include/spacetimedb/internal/v9_builder.h","lineNumber":567,"sourceCode":"    std::vector<uint16_t> field_indexes;\n    \n    // Find field indices for each field name\n    for (const std::string& field_name : field_names) {\n        uint16_t field_idx = 0;\n        bool field_found = false;\n        \n        for (const auto& field_desc : field_descs) {\n            if (field_desc.name == field_name) {\n                field_indexes.push_back(field_idx);\n                field_found = true;\n                //fprintf(stdout, \"DEBUG: Field '%s' -> index %u\\n\", field_name.c_str(), field_idx);\n                break;\n            }\n            field_idx++;\n        }\n        \n        if (!field_found) {\n            fprintf(stderr, \"ERROR: Field '%s' not found in table '%s' for multi-column index\\n\",\n                    field_name.c_str(), table_name.c_str());\n            return;\n        }\n    }\n    \n    // Create the multi-column BTree algorithm\n    RawIndexAlgorithmBTreeData btree_data;\n    btree_data.columns = field_indexes;\n    \n    RawIndexAlgorithm algorithm;\n    algorithm.set<0>(btree_data);  // Set BTree variant\n    \n    // Create the index definition with both the user-provided name and generated btree name\n    RawIndexDefV9 index_def;\n    std::string generated_name = table_name + \"_\" + field_names[0];\n    for (size_t i = 1; i < field_names.size(); ++i) {\n        generated_name += \"_\" + field_names[i];\n    }","sourceCodeStart":549,"sourceCodeEnd":585,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/bindings-cpp/include/spacetimedb/internal/v9_builder.h#L549-L585","documentation":"AddMultiColumnIndex walked the row type's field descriptors but one of the names in field_names matched no field_desc.name, so it aborts the whole index (return, not partial). Every listed column must resolve to a descriptor index before the composite btree is built; one bad name means no index at all.","triggerScenarios":"Any column string in the multi-column index list that doesn't exactly match a registered field name: renamed members, casing differences, listing a column from a different struct, typos introduced when splitting the index across lines.","commonSituations":"Renaming one of the indexed columns during a refactor without updating the index annotation; mixing DB column names and C++ member names; adding a new column to the index before adding it to the struct.","solutions":["Check every field string in the multi-index list against the struct's member names, case-sensitively","After member renames, update all index/constraint/default annotations that mention the old name","Confirm all listed fields belong to the row type passed as T","Republish and confirm the index (generated name '<f0>_<f1>_idx_btree') exists"],"exampleFix":"// before\nstruct Message { uint32_t sender; uint32_t room_id; };\nST_MULTI_INDEX(message, by_sender_room, sender_id, room_id);  // 'sender_id' unknown\n// after\nST_MULTI_INDEX(message, by_sender_room, sender, room_id);","handlingStrategy":"validation","validationCode":"// Validate every listed column resolves before shipping (after init, row type T):\nSpacetimeDB::field_registrar<T>::register_fields();\nconst auto& fields = SpacetimeDB::get_table_descriptors()[&typeid(T)].fields;\nfor (const char* col : {\"sender_id\", \"room_id\"}) {\n    bool ok = std::any_of(fields.begin(), fields.end(),\n        [&](const auto& f){ return f.name == col; });\n    if (!ok) /* fail the build/test */;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Update index column lists in the same change as member renames","Prefer compile-time coupling (macros reading members) over free-form name strings where the bindings allow","Assert published indexes match expectations in a post-publish check"],"tags":["spacetimedb","cpp","schema","unknown-field","multi-column-index","rename"],"backgroundTag":"unknown-schema-field","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}