{"record":{"id":"1d46333e787c9c81","repo":"clockworklabs/SpacetimeDB","slug":"index-idx-sourcename-unknown-on-table","errorCode":null,"errorMessage":"Index '${idx.sourceName ?? '<unknown>'}' on table '${tableDef.sourceName}' is missing accessor name","messagePattern":"Index '(.+?)' on table '(.+?)' is missing accessor name","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"crates/bindings-typescript/src/lib/schema.ts","lineNumber":117,"sourceCode":"  AccName extends string,\n  const T extends UntypedTableSchema,\n>(\n  accName: AccName,\n  schema: T,\n  tableDef: RawTableDefV10\n): TableToSchema<AccName, T> {\n  const getColName = (i: number) =>\n    schema.rowType.algebraicType.value.elements[i].name;\n\n  type AllowedCol = keyof T['rowType']['row'] & string;\n  // Build fully-resolved runtime index metadata from the host-facing RawTableDef.\n  // This is intentionally separate from `schema.idxs`, which keeps the original\n  // user-declared `IndexOpts` shape for type-level inference.\n  const resolvedIndexes: UntypedIndex<AllowedCol>[] = tableDef.indexes.map(\n    idx => {\n      const accessorName = idx.accessorName;\n      if (typeof accessorName !== 'string' || accessorName.length === 0) {\n        throw new TypeError(\n          `Index '${idx.sourceName ?? '<unknown>'}' on table '${tableDef.sourceName}' is missing accessor name`\n        );\n      }\n\n      const columnIds =\n        idx.algorithm.tag === 'Direct'\n          ? [idx.algorithm.value]\n          : idx.algorithm.value;\n\n      const unique = tableDef.constraints.some(\n        c =>\n          c.data.tag === 'Unique' &&\n          c.data.value.columns.every(col => columnIds.includes(col))\n      );\n\n      const algorithm = (\n        {\n          BTree: 'btree',","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/bindings-typescript/src/lib/schema.ts#L99-L135","documentation":"When schema.ts converts the host-facing RawTableDef into the client-side TableToSchema, it builds fully-resolved runtime index metadata and requires every tableDef.indexes[i].accessorName to be a non-empty string, else it throws a TypeError naming the index and table. Because this metadata is produced by the host toolchain, a missing accessorName almost always means the defs came from an older or mismatched producer.","triggerScenarios":"Converting a RawTableDef whose indexes entries lack accessorName - typically a def emitted by an older spacetimedb host/CLI than the TS bindings expect, or a hand-assembled def in tests.","commonSituations":"Version skew between the SpacetimeDB server/tools that generated the table def and the @clockworklabs bindings that consume it; test fixtures hand-rolling RawTableDef JSON without the full index metadata.","solutions":["Align versions: upgrade the spacetimedb toolchain/server and the TS bindings to releases that both emit and require accessorName","If you construct RawTableDef yourself (tests, fixtures), set a non-empty accessorName on every index","If the host genuinely omits the field on current versions, report it upstream with the def JSON"],"exampleFix":"// before\nconst tableDef: RawTableDef = JSON.parse(fixtureJson); // indexes[].accessorName missing -> throws\n\n// after\nfor (const idx of tableDef.indexes) {\n  if (typeof idx.accessorName !== 'string' || idx.accessorName.length === 0) {\n    idx.accessorName = idx.sourceName!; // backfill before conversion\n  }\n}","handlingStrategy":"validation","validationCode":"function validateRawTableDefIndexes(tableDef: { indexes: Array<{ sourceName?: string; accessorName?: unknown }>; sourceName: string }): void {\n  for (const idx of tableDef.indexes) {\n    if (typeof idx.accessorName !== 'string' || idx.accessorName.length === 0) {\n      throw new Error(\n        `tableDef for '${tableDef.sourceName}': index '${idx.sourceName ?? '<unknown>'}' lacks accessorName - host/bindings version mismatch?`\n      );\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the spacetimedb host/toolchain and TS bindings on matched versions","Validate hand-built RawTableDef fixtures with a schema check before conversion","Fail at startup with a clear version-skew message instead of mid-conversion"],"tags":["schema","spacetimedb","index","version-mismatch","host-metadata"],"backgroundTag":"schema-metadata-mismatch","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}