{"record":{"id":"94421d4903ab4eb3","repo":"Budibase/budibase","slug":"calculation-field-name-references-field-sc","errorCode":null,"errorMessage":"Calculation field \"${name}\" references field \"${schema.field}\" which does not exist in the table schema","messagePattern":"Calculation field \"(.+?)\" references field \"(.+?)\" which 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":178,"sourceCode":"  if (Object.keys(calculationFields).length > 5) {\n    throw new HTTPError(\n      \"Calculation views can only have a maximum of 5 fields\",\n      400\n    )\n  }\n\n  for (const name of Object.keys(calculationFields)) {\n    const schema = calculationFields[name]\n    if (!schema.field) {\n      throw new HTTPError(\n        `Calculation field \"${name}\" is missing a \"field\" property`,\n        400\n      )\n    }\n\n    const targetSchema = table.schema[schema.field]\n    if (!targetSchema) {\n      throw new HTTPError(\n        `Calculation field \"${name}\" references field \"${schema.field}\" which does not exist in the table schema`,\n        400\n      )\n    }\n\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","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/views/index.ts#L160-L196","documentation":"A calculation field's field property must reference a column that exists in the underlying table's schema. If table.schema[schema.field] is undefined the guard throws 400, because aggregates cannot run against unknown columns.","triggerScenarios":"Creating/updating a calculation view where the referenced column was renamed or deleted from the table, or the field name is misspelled / wrong-cased.","commonSituations":"Renaming a SQL column after building views on it; deleting a column while views still reference it; typos in scripted view creation; case-sensitive mismatch on external tables.","solutions":["Update the calculation to reference an existing column name from table.schema","Recreate/re-point the view after the column rename","Restore the deleted column or remove the calculation field","Diff the view's field references against the current table schema before saving"],"exampleFix":"// before\ncalculations: { total: { field: \"revenu\", calculationType: \"sum\" } } // typo\n// after\ncalculations: { total: { field: \"revenue\", calculationType: \"sum\" } }","handlingStrategy":"validation","validationCode":"const table = await sdk.tables.getTable(tableId)\nfor (const c of Object.values(view.calculations ?? {})) {\n  if (!(c.field in table.schema)) throw new Error(`Field ${c.field} not in table schema`)\n}","typeGuard":"function fieldExists(table: Table, field: string): boolean { return field in table.schema }","tryCatchPattern":"try { await sdk.views.update(tableId, view) }\ncatch (e) {\n  if (e instanceof HTTPError && e.status === 400 && /does not exist in the table schema/.test(e.message)) {\n    // reload schema, remap fields, retry\n  } else throw e\n}","preventionTips":["Validate calculation targets against a freshly loaded table schema","Re-check views after column renames/deletes","Use schema-aware pickers instead of free-text field input"],"tags":["http-400","views","validation","calculations","schema-mismatch"],"backgroundTag":"schema-validation-failed","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}