{"record":{"id":"3905d238eee36bf4","repo":"windmill-labs/windmill","slug":"table-name-is-required-3905d2","errorCode":null,"errorMessage":"Table name is required","messagePattern":"Table name is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/apps/components/display/dbtable/queries/select.ts","lineNumber":109,"sourceCode":"\tquery += ` ORDER BY ${orderBy.join(',\\n')}`\n\tquery += ` LIMIT ${limit} OFFSET ${offset}`\n\tquery = buildParameters(headers, 'snowflake') + '\\n' + query\n\n\treturn query\n}\n\nexport function makeSelectQuery(\n\ttable: string,\n\tcolumnDefs: ColumnDef[],\n\twhereClause: string | undefined,\n\tdbType: DbType,\n\toptions?: { limit?: number; offset?: number },\n\tbreakingFeatures?: {\n\t\t// These will break existing app policies\n\t\tfixPgIntTypes?: boolean // Everything is casted to text which leads to wrong sorting of numbers\n\t}\n) {\n\tif (!table) throw new Error('Table name is required')\n\tlet quicksearchCondition = ''\n\n\tlet query = buildParameters(\n\t\t[\n\t\t\t{ field: 'limit', datatype: dbType === 'bigquery' ? 'integer' : 'int' },\n\t\t\t{ field: 'offset', datatype: dbType === 'bigquery' ? 'integer' : 'int' },\n\t\t\t{ field: 'quicksearch', datatype: dbType === 'bigquery' ? 'string' : 'text' },\n\t\t\t{ field: 'order_by', datatype: dbType === 'bigquery' ? 'string' : 'text' },\n\t\t\t{ field: 'is_desc', datatype: dbType === 'bigquery' ? 'bool' : 'boolean' }\n\t\t],\n\t\tdbType\n\t)\n\n\tquery += '\\n'\n\n\tconst filteredColumns = buildVisibleFieldList(columnDefs, dbType)\n\tconst selectClause = filteredColumns.join(', ')\n","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/apps/components/display/dbtable/queries/select.ts#L91-L127","documentation":"makeSelectQuery interpolates the table identifier directly into `SELECT ... FROM ${table}`, so an empty table name would yield invalid SQL. The builder throws 'Table name is required' up front. Like the other builders here it powers the legacy Database Studio dbtable, where table state may legitimately be unset while the component initializes.","triggerScenarios":"Calling makeSelectQuery (via content/query) with table === '' — component rendered before a table is chosen, table bound to an undefined URL/state variable, or saved app config missing the table.","commonSituations":"Opening a Database Studio app whose table selection was never saved; dynamic table names resolved from context that resolves late; refetch triggered on mount before selection completes.","solutions":["Guard the call site: skip the query until a table is selected (or disable the component).","Persist/restore the table selection so refreshes don't blank it.","If the table should be fixed, set it statically in the app config instead of via bindings."],"exampleFix":"// before\nconst rows = await query(makeSelectQuery(table, cols, dbType))\n// after\nif (!table) return [] // wait for table selection\nconst rows = await query(makeSelectQuery(table, cols, dbType))","handlingStrategy":"validation","validationCode":"if (!table || typeof table !== 'string' || !table.trim()) {\n  return [] // or skip fetching until a table is selected\n}","typeGuard":"const isNonEmptyString = (v: unknown): v is string =>\n  typeof v === 'string' && v.trim().length > 0","tryCatchPattern":"try {\n  const q = makeSelectQuery(table, columns, dbType)\n} catch (e) {\n  if (e instanceof Error && e.message === 'Table name is required') {\n    setNeedsTableSelection(true)\n    return\n  }\n  throw e\n}","preventionTips":["Only run table queries after a table is selected; render a picker otherwise","Persist table selection in state/URL params","Validate table-name bindings resolve non-empty before fetch","Guard all legacy dbtable builders (select/count/insert/delete) with the same table check"],"tags":["database","validation","missing-argument","select"],"backgroundTag":"missing-required-argument","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"}