Budibase/budibase · error · HTTPError

Group by field "${groupByFieldName}" does not exist in the t

Error message

Group by field "${groupByFieldName}" does not exist in the table schema

What it means

Every group-by (basic) field of a calculation view must exist in the underlying table schema. If table.schema[groupByFieldName] is missing the guard throws 400 before even checking whether the type is groupable.

Source

Thrown at packages/server/src/sdk/workspace/views/index.ts:201

    const isCount = schema.calculationType === CalculationType.COUNT
    if (
      !isCount &&
      !isNumeric(targetSchema.type) &&
      !isNumericStaticFormula(targetSchema)
    ) {
      throw new HTTPError(
        `Calculation field "${name}" references field "${schema.field}" which is not a numeric field`,
        400
      )
    }
  }

  const groupByFields = helpers.views.basicFields(view)
  for (const groupByFieldName of Object.keys(groupByFields)) {
    const targetSchema = table.schema[groupByFieldName]
    if (!targetSchema) {
      throw new HTTPError(
        `Group by field "${groupByFieldName}" does not exist in the table schema`,
        400
      )
    }

    if (!canGroupBySchema(targetSchema)) {
      throw new HTTPError(
        `Grouping by fields of type "${targetSchema.type}" is not supported`,
        400
      )
    }
  }
}

async function guardViewSchema(
  tableId: string,
  view: Omit<ViewV2, "id" | "version">
) {

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Update the group-by list to use existing column names from table.schema
  2. Remove the stale group-by field from the view
  3. Restore the renamed/deleted column or migrate the view after schema changes

Example fix

// before
groupBy: ["region "], // trailing space / stale name
// after
groupBy: ["region"] // must exist in table.schema
Defensive patterns

Strategy: validation

Validate before calling

const table = await sdk.tables.getTable(tableId)
for (const g of Object.keys(view.groupBy ?? {})) {
  if (!(g in table.schema)) throw new Error(`Group-by field ${g} not in table schema`)
}

Type guard

function canGroup(table: Table, field: string): boolean {
  const s = table.schema[field]
  return !!s && canGroupBySchema(s)
}

Try / catch

try { await sdk.views.update(tableId, view) }
catch (e) {
  if (e instanceof HTTPError && e.status === 400 && /Group by field .* does not exist/.test(e.message)) {
    // refresh schema, fix groupBy list, retry
  } else throw e
}

Prevention

When it happens

Trigger: Creating/updating a calculation view whose group-by list references a renamed or deleted column, or contains a misspelled field name.

Common situations: Grouping by a column removed from the table; schema drift on external SQL tables; scripted view definitions with stale field names; case mismatches.

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 Budibase/budibase@a81a902e9a (2026-08-29). Data as JSON: /api/errors/409d15fd43163b61. Report an issue: GitHub.