{"record":{"id":"befc647d8631e5f9","repo":"windmill-labs/windmill","slug":"table-name-is-required","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/insert.ts","lineNumber":94,"sourceCode":"\t\t\tthrow new Error(`Column ${column.field} is not nullable and has no default value`)\n\t\t}\n\n\t\tif (!userDefaultValue && !dbDefaultValue) {\n\t\t\t// Should be omitted if it's an identity column and we have no default value\n\t\t\treturn column.isidentity !== ColumnIdentity.No\n\t\t}\n\n\t\t// Should be omitted if the user had not provided a default value and the database has a default value\n\t\treturn !userDefaultValue && dbDefaultValue\n\t} else if (column.isnullable === 'YES') {\n\t\treturn !userDefaultValue\n\t}\n\n\treturn false\n}\n\nexport function makeInsertQuery(table: string, columns: ColumnDef[], dbType: DbType) {\n\tif (!table) throw new Error('Table name is required')\n\n\tconst columnsInsert = columns.filter(\n\t\t(x) => !x.hideInsert && !(dbType == 'postgresql' && x.defaultvalue?.startsWith('nextval('))\n\t)\n\tconst columnsDefault = columns.filter((c) => !shouldOmitColumnInInsert(c))\n\tconst allInsertColumns = columnsInsert.concat(columnsDefault)\n\n\tlet query = buildParameters(columnsInsert, dbType)\n\n\tquery += '\\n'\n\n\tconst shouldInsertComma = columnsDefault.length > 0\n\tconst columnNames = formatColumnNames(allInsertColumns)\n\tconst insertValues = formatInsertValues(columnsInsert, dbType)\n\tconst defaultValues = formatDefaultValues(columnsDefault)\n\tconst commaOrEmpty = shouldInsertComma ? ', ' : ''\n\tconst valuesStr = `${insertValues}${commaOrEmpty}${defaultValues}`\n","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/apps/components/display/dbtable/queries/insert.ts#L76-L112","documentation":"makeInsertQuery requires a non-empty table name because it interpolates the table identifier directly into `INSERT INTO ${table}`. An empty string would produce invalid SQL ('INSERT INTO  (…)'), so the builder fails fast with 'Table name is required'. This is a guard against misconfigured table-state in the dbtable component.","triggerScenarios":"Calling makeInsertQuery (via getInsertInput/query) with table === '' — e.g. the table editor rendered before a table was selected, state loss on refresh, or a saved app whose table binding evaluated to empty.","commonSituations":"User opens the insert dialog of a Database Studio app before picking a table; the table name comes from a variable/URL param that is undefined at build time; app state was saved without a table selection.","solutions":["Ensure a table is selected before invoking the insert flow; disable the insert UI while table is empty.","Default the table from state/URL params and guard the call site: only build the query when table is truthy.","Fix the saved app config so the table name is statically set if it was intended to be constant."],"exampleFix":"// before\nconst input = getInsertInput(dbInput, table, columns)\n// after\nif (!table) throw new Error('Select a table before inserting rows')\nconst input = getInsertInput(dbInput, table, columns)","handlingStrategy":"validation","validationCode":"if (typeof table !== 'string' || !table.trim()) {\n  throw new Error('Select a table before inserting rows')\n}","typeGuard":"const hasTable = (t: unknown): t is string =>\n  typeof t === 'string' && t.trim().length > 0","tryCatchPattern":"try {\n  return getInsertInput(dbInput, table, columns)\n} catch (e) {\n  if (e instanceof Error && e.message === 'Table name is required') {\n    showToast('Select a table first')\n    return null\n  }\n  throw e\n}","preventionTips":["Disable insert/delete/edit buttons while no table is selected","Persist the selected table in app state or URL so it survives refreshes","Validate bindings that supply table names resolve before the component mounts"],"tags":["database","validation","missing-argument","insert"],"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"}