{"record":{"id":"409d15fd43163b61","repo":"Budibase/budibase","slug":"group-by-field-groupbyfieldname-does-not-exis","errorCode":null,"errorMessage":"Group by field \"${groupByFieldName}\" does not exist in the table schema","messagePattern":"Group by field \"(.+?)\" does not exist in the table schema","errorType":"validation","errorClass":"HTTPError","httpStatus":400,"severity":"error","filePath":"packages/server/src/sdk/workspace/views/index.ts","lineNumber":201,"sourceCode":"\n    const isCount = schema.calculationType === CalculationType.COUNT\n    if (\n      !isCount &&\n      !isNumeric(targetSchema.type) &&\n      !isNumericStaticFormula(targetSchema)\n    ) {\n      throw new HTTPError(\n        `Calculation field \"${name}\" references field \"${schema.field}\" which is not a numeric field`,\n        400\n      )\n    }\n  }\n\n  const groupByFields = helpers.views.basicFields(view)\n  for (const groupByFieldName of Object.keys(groupByFields)) {\n    const targetSchema = table.schema[groupByFieldName]\n    if (!targetSchema) {\n      throw new HTTPError(\n        `Group by field \"${groupByFieldName}\" does not exist in the table schema`,\n        400\n      )\n    }\n\n    if (!canGroupBySchema(targetSchema)) {\n      throw new HTTPError(\n        `Grouping by fields of type \"${targetSchema.type}\" is not supported`,\n        400\n      )\n    }\n  }\n}\n\nasync function guardViewSchema(\n  tableId: string,\n  view: Omit<ViewV2, \"id\" | \"version\">\n) {","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/views/index.ts#L183-L219","documentation":"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.","triggerScenarios":"Creating/updating a calculation view whose group-by list references a renamed or deleted column, or contains a misspelled field name.","commonSituations":"Grouping by a column removed from the table; schema drift on external SQL tables; scripted view definitions with stale field names; case mismatches.","solutions":["Update the group-by list to use existing column names from table.schema","Remove the stale group-by field from the view","Restore the renamed/deleted column or migrate the view after schema changes"],"exampleFix":"// before\ngroupBy: [\"region \"], // trailing space / stale name\n// after\ngroupBy: [\"region\"] // must exist in table.schema","handlingStrategy":"validation","validationCode":"const table = await sdk.tables.getTable(tableId)\nfor (const g of Object.keys(view.groupBy ?? {})) {\n  if (!(g in table.schema)) throw new Error(`Group-by field ${g} not in table schema`)\n}","typeGuard":"function canGroup(table: Table, field: string): boolean {\n  const s = table.schema[field]\n  return !!s && canGroupBySchema(s)\n}","tryCatchPattern":"try { await sdk.views.update(tableId, view) }\ncatch (e) {\n  if (e instanceof HTTPError && e.status === 400 && /Group by field .* does not exist/.test(e.message)) {\n    // refresh schema, fix groupBy list, retry\n  } else throw e\n}","preventionTips":["Validate group-by fields against current table schema before saving","Refresh views after external schema syncs","Use schema-driven multi-select for group-by fields"],"tags":["http-400","views","validation","group-by","schema-mismatch"],"backgroundTag":"schema-validation-failed","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}