{"record":{"id":"aaa2335ebbc9a17e","repo":"windmill-labs/windmill","slug":"unimplemented-case","errorCode":null,"errorMessage":"Unimplemented case","messagePattern":"Unimplemented case","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/apps/components/display/dbtable/queries/alterTable.ts","lineNumber":150,"sourceCode":"\t\t\t\t\t// Snowflake requires CONSTRAINT syntax with explicit name\n\t\t\t\t\tconst constraintName = `${values.name}_pk`\n\t\t\t\t\tqueries.push(\n\t\t\t\t\t\t`ALTER TABLE ${tableRef} ADD CONSTRAINT ${constraintName} PRIMARY KEY (${op.columns.join(', ')});`\n\t\t\t\t\t)\n\t\t\t\t} else {\n\t\t\t\t\tconst notEnforced = dbType === 'bigquery' ? ' NOT ENFORCED' : ''\n\t\t\t\t\tqueries.push(\n\t\t\t\t\t\t`ALTER TABLE ${tableRef} ADD PRIMARY KEY (${op.columns.join(', ')})${notEnforced};`\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tbreak\n\n\t\t\tcase 'dropPrimaryKey':\n\t\t\t\tqueries.push(renderDropPrimaryKey(tableRef, dbType, op.pk_constraint_name))\n\t\t\t\tbreak\n\n\t\t\tdefault:\n\t\t\t\tthrow new Error('Unimplemented case')\n\t\t}\n\t}\n\n\treturn queries\n}\n\nfunction renderAlterColumn(tableRef: string, op: AlterColumnOperation, dbType: DbType): string[] {\n\tconst queries: string[] = []\n\tconst { changes, original } = op\n\n\tconst baseDatatype = changes.datatype ?? original.datatype\n\tconst datatypeLength = datatypeHasLength(baseDatatype)\n\t\t? (changes.datatype_length ?? original.datatype_length)\n\t\t: undefined\n\tconst datatype = datatypeLength ? `${baseDatatype}(${datatypeLength})` : baseDatatype\n\n\tif (changes.datatype || changes.datatype_length) {\n\t\tqueries.push(renderAlterDatatype(tableRef, original.name, datatype, dbType))","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/apps/components/display/dbtable/queries/alterTable.ts#L132-L168","documentation":"makeAlterTableQueries() walks the pending table-editor operations and switches on op.kind to render SQL. The default branch throws 'Unimplemented case' when an operation kind reaches the switch that no case handles — i.e. an operation type added to AlterTableOperation (or a corrupted/hand-built operation object) without a corresponding SQL renderer here.","triggerScenarios":"Passing an AlterTableValues whose operations array contains an op.kind not among addColumn/dropColumn/alterColumn/addForeignKey/dropForeignKey/renameTable/addPrimaryKey/dropPrimaryKey — e.g. a new operation kind introduced upstream in the table editor but not handled in this switch, or an operation object with an undefined/typo'd kind.","commonSituations":"A version mismatch between the table-editor UI (emitting a new operation kind) and this query builder; plugin/scripted edits that push hand-crafted operations into the editor state; data corrupted in transit leaving kind undefined.","solutions":["Inspect the offending operation in the thrown context (log values.operations) to see the unhandled kind.","Update Windmill frontend to matching versions on both sides if UI and query builder diverged.","If developing: add a case for the new op.kind in the switch (or remove the operation from the producer).","Validate op.kind against the union type before calling makeAlterTableQueries when building operations programmatically."],"exampleFix":"// before\ncase 'dropPrimaryKey':\n  queries.push(renderDropPrimaryKey(tableRef, dbType, op.pk_constraint_name))\n  break\ndefault:\n  throw new Error('Unimplemented case')\n// after\ndefault:\n  assertNever(op) // exhaustive check: surfaces the missing kind at compile time","handlingStrategy":"validation","validationCode":"const knownKinds = ['addColumn','dropColumn','alterColumn','addForeignKey','dropForeignKey','renameTable','addPrimaryKey','dropPrimaryKey']\nconst bad = values.operations.filter(op => !knownKinds.includes(op.kind))\nif (bad.length) throw new Error('Unknown operation kinds: ' + bad.map(o => o.kind).join(','))","typeGuard":"function isKnownOperation(op: { kind: string }): op is AlterTableOperation {\n  return ['addColumn','dropColumn','alterColumn','addForeignKey','dropForeignKey','renameTable','addPrimaryKey','dropPrimaryKey'].includes(op.kind)\n}","tryCatchPattern":"try {\n  const queries = makeAlterTableQueries(values, dbType, schema)\n} catch (e) {\n  console.error('alter-table op dispatch failed', values.operations, e)\n  throw e\n}","preventionTips":["Keep AlterTableOperation union and the switch exhaustive; use an assertNever() default branch so gaps fail at compile time.","Never push hand-built operations into the editor state.","Keep frontend components and this builder in the same version."],"tags":["frontend","sql","dbtable","exhaustiveness"],"backgroundTag":"unhandled-switch-case","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}