{"record":{"id":"14d9ca9294f64eec","repo":"Budibase/budibase","slug":"grouping-by-fields-of-type-targetschema-type","errorCode":null,"errorMessage":"Grouping by fields of type \"${targetSchema.type}\" is not supported","messagePattern":"Grouping by fields of type \"(.+?)\" is not supported","errorType":"validation","errorClass":"HTTPError","httpStatus":400,"severity":"error","filePath":"packages/server/src/sdk/workspace/views/index.ts","lineNumber":208,"sourceCode":"      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) {\n  const table = await sdk.tables.getTable(tableId)\n\n  if (helpers.views.isCalculationView(view)) {\n    await guardCalculationViewSchema(table, view)\n  } else {\n    if (helpers.views.hasCalculationFields(view)) {\n      throw new HTTPError(","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/views/index.ts#L190-L226","documentation":"Thrown by guardCalculationViewSchema when a calculation view declares a group-by field whose table schema type is not in the set of types that support grouping (via canGroupBySchema). Budibase views can only group by certain field types (e.g. strings, options); grouping by types like JSON, attachments, or formulas is rejected with a 400. It is a static config validation, not a runtime data failure.","triggerScenarios":"Creating or updating a calculation view (sdk.views.create/update -> guardViewSchema) with view.groupBy set to a field whose table.schema[fieldName].type is unsupported by canGroupBySchema.","commonSituations":"Grouping by a formula, JSON, multi-select, attachment, or link field added to the table after the view was configured; copying view configs between tables with different field types; UI workarounds that bypass type filtering.","solutions":["Change the groupBy field in the view to one whose type is supported (e.g. string, number, boolean, option).","If the field must stay, change the table column type to a groupable type or add a supported computed/text column to group on.","Remove the groupBy from the view if grouping is not essential.","Check canGroupBySchema in packages/server for the exact supported type list before configuring."],"exampleFix":"// before\nview.groupBy = \"metadata\" // metadata: { type: \"json\" }\n// after\nview.groupBy = \"status\" // status: { type: \"string\" }","handlingStrategy":"validation","validationCode":"const SUPPORTED = [\"string\", \"number\", \"boolean\", \"longform\", \"options\"]\nif (view.groupBy && !SUPPORTED.includes(table.schema[view.groupBy]?.type)) {\n  throw new Error(`Cannot group by ${view.groupBy}`)\n}\nawait sdk.views.create(view)","typeGuard":"function isGroupable(field: FieldSchema | undefined): boolean {\n  return !!field && [\"string\", \"number\", \"boolean\", \"longform\", \"options\"].includes(field.type)\n}","tryCatchPattern":"try {\n  await sdk.views.update(view)\n} catch (e) {\n  if (e instanceof HTTPError && e.status === 400 && e.message.includes(\"Grouping by fields of type\")) {\n    view.groupBy = undefined\n    await sdk.views.update(view)\n  } else { throw e }\n}","preventionTips":["Check canGroupBySchema / supported types before assigning groupBy","Filter the group-by picker in UIs to supported field types","Re-validate view configs after changing table column types"],"tags":["validation","views","schema"],"backgroundTag":"unsupported-field-type","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}