{"record":{"id":"37e3938edecbd93f","repo":"clockworklabs/SpacetimeDB","slug":"invalid-sequence-type","errorCode":null,"errorMessage":"invalid sequence type","messagePattern":"invalid sequence type","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"crates/bindings-typescript/src/server/runtime.ts","lineNumber":1114,"sourceCode":"    switch (colType.tag) {\n      case 'U8':\n      case 'I8':\n      case 'U16':\n      case 'I16':\n      case 'U32':\n      case 'I32':\n        sequenceTrigger = 0;\n        break;\n      case 'U64':\n      case 'I64':\n      case 'U128':\n      case 'I128':\n      case 'U256':\n      case 'I256':\n        sequenceTrigger = 0n;\n        break;\n      default:\n        throw new TypeError('invalid sequence type');\n    }\n    return {\n      colName: col.name!,\n      sequenceTrigger,\n      deserialize: AlgebraicType.makeDeserializer(colType, typespace),\n    };\n  });\n  const hasAutoIncrement = sequences.length > 0;\n\n  const iter = () =>\n    tableIterator(sys.datastore_table_scan_bsatn(table_id), deserializeRow);\n\n  const integrateGeneratedColumns = hasAutoIncrement\n    ? (row: RowType<any>, ret_buf: DataView) => {\n        BINARY_READER.reset(ret_buf);\n        for (const { colName, deserialize, sequenceTrigger } of sequences) {\n          if (row[colName] === sequenceTrigger) {\n            row[colName] = deserialize(BINARY_READER);","sourceCodeStart":1096,"sourceCodeEnd":1132,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/bindings-typescript/src/server/runtime.ts#L1096-L1132","documentation":"When the runtime builds table accessors, it computes a placeholder 'trigger' value for every auto-increment (sequence) column: numeric 0 for integer types that fit a JS number (U8/I8/U16/I16/U32/I32) and 0n for 64-256-bit integers (U64/I64/U128/I128/U256/I256). Any other column type has no valid trigger, so table setup throws TypeError('invalid sequence type') at module start.","triggerScenarios":"A sequence/auto-increment column whose algebraic type is not one of the eight supported integer types: a string, bool, identity, or product/sum type column marked auto-increment; hand-edited or stale codegen emitting sequence metadata with a non-integer column type.","commonSituations":"Porting SQL schemas with AUTO_INCREMENT assumptions; manually editing generated schema/type definitions; codegen version mismatch that emits sequence metadata the runtime rejects.","solutions":["Change the auto-increment column to a supported integer type (I32/U32 for small ranges, U64 for large ones)","Remove the auto-increment/sequence attribute from the non-integer column","Regenerate module code from the schema instead of hand-editing type definitions"],"exampleFix":"// before: auto-inc sequence declared on a non-integer column\n// table Users { name: string /* marked auto-inc */ }\n\n// after: integer auto-inc column\n// table Users { id: u64 /* auto-inc */ }\n// insert 0 (small ints) or 0n (64+ bit ints) to request the generated value","handlingStrategy":"validation","validationCode":"const SEQUENCE_SUPPORTED = new Set([\n  'U8', 'I8', 'U16', 'I16', 'U32', 'I32', 'U64', 'I64', 'U128', 'I128', 'U256', 'I256',\n]);\nfunction assertSequenceColumnOk(typeTag: string, colName: string): void {\n  if (!SEQUENCE_SUPPORTED.has(typeTag)) {\n    throw new Error(`auto-inc column '${colName}' must be an integer type, got ${typeTag}`);\n  }\n}","typeGuard":"const isSequenceSupportedType = (tag: string): tag is\n  'U8' | 'I8' | 'U16' | 'I16' | 'U32' | 'I32' | 'U64' | 'I64' | 'U128' | 'I128' | 'U256' | 'I256' =>\n  SEQUENCE_SUPPORTED.has(tag);","tryCatchPattern":null,"preventionTips":["Only mark integer columns as auto-increment; strings/bools/identity columns never qualify","Regenerate schema code from source instead of hand-editing generated type metadata","Add a schema lint that checks every sequence column's type against the supported integer set"],"tags":["schema","auto-increment","table","typescript"],"backgroundTag":"unsupported-column-type","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}