{"record":{"id":"6b1dad63aec28acd","repo":"windmill-labs/windmill","slug":"unsupported-database-type-dbtype-6b1dad","errorCode":null,"errorMessage":"Unsupported database type:${dbType}","messagePattern":"Unsupported database type:(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/apps/components/display/dbtable/queries/count.ts","lineNumber":135,"sourceCode":"\t\t\t\tquicksearchCondition += `(@quicksearch = '' OR REGEXP_CONTAINS(CONCAT(${searchClause}), '(?i)' || @quicksearch))`\n\t\t\t} else {\n\t\t\t\tquicksearchCondition += `(@quicksearch = '' OR 1 = 1)`\n\t\t\t}\n\t\t\tquery += `SELECT COUNT(*) as count FROM \\`${table}\\``\n\t\t\tbreak\n\t\t}\n\t\tcase 'duckdb':\n\t\t\tif (filteredColumns.length > 0) {\n\t\t\t\tquicksearchCondition += ` ($quicksearch = '' OR CONCAT(' ', ${duckdbQuicksearchColumns(\n\t\t\t\t\tcolumnDefs\n\t\t\t\t)}) LIKE CONCAT('%', $quicksearch, '%'))`\n\t\t\t} else {\n\t\t\t\tquicksearchCondition += ` ($quicksearch = '' OR 1 = 1)`\n\t\t\t}\n\t\t\tquery += `SELECT COUNT(*) as count FROM ${table}`\n\t\t\tbreak\n\t\tdefault:\n\t\t\tthrow new Error('Unsupported database type:' + dbType)\n\t}\n\n\tif (whereClause) {\n\t\tquery += `${wherePrefix}${quicksearchCondition}`\n\t} else {\n\t\tquery += dbType === 'ms_sql_server' && !whereClause ? wherePrefix : andCondition\n\t\tquery += quicksearchCondition\n\t}\n\n\tif (\n\t\t!whereClause &&\n\t\t(dbType === 'mysql' ||\n\t\t\tdbType === 'postgresql' ||\n\t\t\tdbType === 'snowflake' ||\n\t\t\tdbType === 'bigquery' ||\n\t\t\tdbType === 'duckdb')\n\t) {\n\t\tquery = query.replace(`${andCondition}`, wherePrefix)","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/apps/components/display/dbtable/queries/count.ts#L117-L153","documentation":"makeCountQuery builds a frontend COUNT(*) query for the legacy Database Studio dbtable and switches on dbType to pick the right parameter/quicksearch syntax. When dbType matches none of the supported cases (mysql, postgresql, ms_sql_server, snowflake, bigquery, duckdb, etc.) the default branch throws. This guards against silently generating invalid SQL for a resource type the builder cannot handle.","triggerScenarios":"Calling makeCountQuery (via the dbtable query runner) with a dbType string outside the switch cases — e.g. a newly added resource type, a typo'd/legacy resourceType on the database resource, or a dbInput whose type was not normalized (such as 'ducklake' passed unmapped) before reaching this function.","commonSituations":"A new database integration was added to Windmill but this legacy query builder was not extended; a resource was created with an unusual/renamed type; a custom or copy-pasted app config references a resourceType the switch doesn't know; stale saved app state carries an old dbType value.","solutions":["Check the dbType/resourceType of the database resource feeding the dbtable component and confirm it is one of the types in the switch (mysql, postgresql, ms_sql_server, snowflake, bigquery, duckdb).","If using a ducklake input, ensure it is mapped to 'duckdb' before calling (getCountInput-style wrappers do `dbInput.type === 'ducklake' ? 'duckdb' : dbInput.resourceType`).","If you added a new DB integration, extend the switch in makeCountQuery with its parameter-placeholder and quicksearch syntax, or use the new Database Manager (WM_INTERNAL_DB) path instead of this legacy builder.","Log the incoming dbType at the call site (query) to see the exact offending value."],"exampleFix":"// before\nconst dbType = dbInput.resourceType\nconst q = makeCountQuery(dbType, table, where, columns)\n// after\nconst dbType = dbInput.type === 'ducklake' ? 'duckdb' : dbInput.resourceType\nconst SUPPORTED = ['mysql','postgresql','ms_sql_server','snowflake','bigquery','duckdb']\nif (!SUPPORTED.includes(dbType)) throw new Error(`DB Studio table editor does not support ${dbType}`)\nconst q = makeCountQuery(dbType, table, where, columns)","handlingStrategy":"validation","validationCode":"const SUPPORTED = ['mysql','postgresql','ms_sql_server','snowflake','bigquery','duckdb']\nconst dbType = dbInput.type === 'ducklake' ? 'duckdb' : dbInput.resourceType\nif (!SUPPORTED.includes(dbType)) {\n  throw new Error(`Database Studio table editor does not support dbType \"${dbType}\"`)\n}","typeGuard":"function isSupportedDbType(t: string): t is DbType {\n  return ['mysql','postgresql','ms_sql_server','snowflake','bigquery','duckdb'].includes(t)\n}","tryCatchPattern":"try {\n  const q = makeCountQuery(dbType, table, where, columns)\n} catch (e) {\n  if (String(e?.message).startsWith('Unsupported database type')) {\n    console.warn('dbtable count unsupported for', dbType)\n    return { count: 0 }\n  }\n  throw e\n}","preventionTips":["Normalize ducklake inputs to 'duckdb' before any legacy query builder call","Whitelist dbType against the switch cases before calling make*Query functions","When adding a new DB integration, grep dbtable/queries/ for every switch to update","Prefer the Database Manager (WM_INTERNAL_DB) path over legacy frontend builders"],"tags":["database","sql-generation","unsupported-type","legacy-code"],"backgroundTag":"unsupported-database-type","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"}