windmill-labs/windmill · error

Table name is required

Error message

Table name is required

What it means

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.

Source

Thrown at frontend/src/lib/components/apps/components/display/dbtable/queries/select.ts:109

	query += ` ORDER BY ${orderBy.join(',\n')}`
	query += ` LIMIT ${limit} OFFSET ${offset}`
	query = buildParameters(headers, 'snowflake') + '\n' + query

	return query
}

export function makeSelectQuery(
	table: string,
	columnDefs: ColumnDef[],
	whereClause: string | undefined,
	dbType: DbType,
	options?: { limit?: number; offset?: number },
	breakingFeatures?: {
		// These will break existing app policies
		fixPgIntTypes?: boolean // Everything is casted to text which leads to wrong sorting of numbers
	}
) {
	if (!table) throw new Error('Table name is required')
	let quicksearchCondition = ''

	let query = buildParameters(
		[
			{ field: 'limit', datatype: dbType === 'bigquery' ? 'integer' : 'int' },
			{ field: 'offset', datatype: dbType === 'bigquery' ? 'integer' : 'int' },
			{ field: 'quicksearch', datatype: dbType === 'bigquery' ? 'string' : 'text' },
			{ field: 'order_by', datatype: dbType === 'bigquery' ? 'string' : 'text' },
			{ field: 'is_desc', datatype: dbType === 'bigquery' ? 'bool' : 'boolean' }
		],
		dbType
	)

	query += '\n'

	const filteredColumns = buildVisibleFieldList(columnDefs, dbType)
	const selectClause = filteredColumns.join(', ')

View on GitHub (pinned to e474e8803c)

Solutions

  1. Guard the call site: skip the query until a table is selected (or disable the component).
  2. Persist/restore the table selection so refreshes don't blank it.
  3. If the table should be fixed, set it statically in the app config instead of via bindings.

Example fix

// before
const rows = await query(makeSelectQuery(table, cols, dbType))
// after
if (!table) return [] // wait for table selection
const rows = await query(makeSelectQuery(table, cols, dbType))
Defensive patterns

Strategy: validation

Validate before calling

if (!table || typeof table !== 'string' || !table.trim()) {
  return [] // or skip fetching until a table is selected
}

Type guard

const isNonEmptyString = (v: unknown): v is string =>
  typeof v === 'string' && v.trim().length > 0

Try / catch

try {
  const q = makeSelectQuery(table, columns, dbType)
} catch (e) {
  if (e instanceof Error && e.message === 'Table name is required') {
    setNeedsTableSelection(true)
    return
  }
  throw e
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/3905d238eee36bf4. Report an issue: GitHub.