windmill-labs/windmill · error
Unimplemented case
Error message
Unimplemented case
What it means
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.
Source
Thrown at frontend/src/lib/components/apps/components/display/dbtable/queries/alterTable.ts:150
// Snowflake requires CONSTRAINT syntax with explicit name
const constraintName = `${values.name}_pk`
queries.push(
`ALTER TABLE ${tableRef} ADD CONSTRAINT ${constraintName} PRIMARY KEY (${op.columns.join(', ')});`
)
} else {
const notEnforced = dbType === 'bigquery' ? ' NOT ENFORCED' : ''
queries.push(
`ALTER TABLE ${tableRef} ADD PRIMARY KEY (${op.columns.join(', ')})${notEnforced};`
)
}
break
case 'dropPrimaryKey':
queries.push(renderDropPrimaryKey(tableRef, dbType, op.pk_constraint_name))
break
default:
throw new Error('Unimplemented case')
}
}
return queries
}
function renderAlterColumn(tableRef: string, op: AlterColumnOperation, dbType: DbType): string[] {
const queries: string[] = []
const { changes, original } = op
const baseDatatype = changes.datatype ?? original.datatype
const datatypeLength = datatypeHasLength(baseDatatype)
? (changes.datatype_length ?? original.datatype_length)
: undefined
const datatype = datatypeLength ? `${baseDatatype}(${datatypeLength})` : baseDatatype
if (changes.datatype || changes.datatype_length) {
queries.push(renderAlterDatatype(tableRef, original.name, datatype, dbType))View on GitHub (pinned to e474e8803c)
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.
Example fix
// before
case 'dropPrimaryKey':
queries.push(renderDropPrimaryKey(tableRef, dbType, op.pk_constraint_name))
break
default:
throw new Error('Unimplemented case')
// after
default:
assertNever(op) // exhaustive check: surfaces the missing kind at compile time Defensive patterns
Strategy: validation
Validate before calling
const knownKinds = ['addColumn','dropColumn','alterColumn','addForeignKey','dropForeignKey','renameTable','addPrimaryKey','dropPrimaryKey']
const bad = values.operations.filter(op => !knownKinds.includes(op.kind))
if (bad.length) throw new Error('Unknown operation kinds: ' + bad.map(o => o.kind).join(',')) Type guard
function isKnownOperation(op: { kind: string }): op is AlterTableOperation {
return ['addColumn','dropColumn','alterColumn','addForeignKey','dropForeignKey','renameTable','addPrimaryKey','dropPrimaryKey'].includes(op.kind)
} Try / catch
try {
const queries = makeAlterTableQueries(values, dbType, schema)
} catch (e) {
console.error('alter-table op dispatch failed', values.operations, e)
throw e
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Unsupported database type: ${dbType}
- Original foreign key missing constraint name : ${JSON.string
- Unsupported database type
- Unsupported database type
- Unsupported database type: ${dbType}
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/aaa2335ebbc9a17e.
Report an issue: GitHub.