remix-run/remix · error · Error

Option "{optionName}" for table "{getTableName(table)}" must

Error message

Option "{optionName}" for table "{getTableName(table)}" must not be empty

What it means

Table options like unique constraints or indexes that accept a column selector reject empty arrays: at least one column must be selected. This error names the option that received an empty selector.

Source

Thrown at packages/data-table/src/lib/table.ts:1138

  defaultValue: readonly string[],
): string[] {
  return normalizeKeysForTable(table, selector, optionName, defaultValue)
}

function normalizeKeysForTable(
  table: AnyTable,
  selector: string | readonly string[] | undefined,
  optionName: string,
  defaultValue: readonly string[],
): string[] {
  if (selector === undefined) {
    return [...defaultValue]
  }

  let keys = Array.isArray(selector) ? [...selector] : [selector]

  if (keys.length === 0) {
    throw new Error(
      'Option "' + optionName + '" for table "' + getTableName(table) + '" must not be empty',
    )
  }

  let columns = getTableColumns(table)

  for (let key of keys) {
    if (!Object.prototype.hasOwnProperty.call(columns, key)) {
      throw new Error(
        'Unknown column "' +
          key +
          '" in option "' +
          optionName +
          '" for table "' +
          getTableName(table) +
          '"',
      )
    }

View on GitHub (pinned to 9696913134)

Solutions

  1. Ensure the option's column list has at least one entry
  2. Skip the option entirely when the dynamic list is empty
  3. Check spreads/defaults are not replacing the list with an empty array

Example fix

// before
createTable('t', cols, { unique: maybeKeys })
// after
createTable('t', cols, maybeKeys.length ? { unique: maybeKeys } : {})
Defensive patterns

Strategy: validation

Validate before calling

if (selector.length === 0) throw new Error('selector must not be empty')

Prevention

When it happens

Trigger: Passing unique: [] or index: [] (or a selector that spreads an empty array) in a table's options.

Common situations: Options built dynamically from config or metadata lists that are empty in some cases; defaults that unintentionally override a populated selector.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of remix-run/remix@9696913134 (2026-08-27). Data as JSON: /api/errors/f8d6a39c28fa4283. Report an issue: GitHub.