{"record":{"id":"55f605842c659348","repo":"Budibase/budibase","slug":"field-field-is-not-valid-for-the-requested-ta","errorCode":null,"errorMessage":"Field \"${field}\" is not valid for the requested table","messagePattern":"Field \"(.+?)\" is not valid for the requested table","errorType":"validation","errorClass":"HTTPError","httpStatus":400,"severity":"error","filePath":"packages/server/src/sdk/workspace/views/index.ts","lineNumber":260,"sourceCode":"  ensureValidPrimaryDisplay(view, table)\n\n  checkDisplayField(view)\n}\n\nasync function checkReadonlyFields(\n  table: Table,\n  view: Omit<ViewV2, \"id\" | \"version\">\n) {\n  const viewSchema = view.schema || {}\n  for (const field of Object.keys(viewSchema)) {\n    const viewFieldSchema = viewSchema[field]\n    if (helpers.views.isCalculationField(viewFieldSchema)) {\n      continue\n    }\n\n    const tableFieldSchema = table.schema[field]\n    if (!tableFieldSchema) {\n      throw new HTTPError(\n        `Field \"${field}\" is not valid for the requested table`,\n        400\n      )\n    }\n\n    if (viewSchema[field].readonly) {\n      if (!viewSchema[field].visible) {\n        throw new HTTPError(\n          `Field \"${field}\" must be visible if you want to make it readonly`,\n          400\n        )\n      }\n    }\n  }\n}\n\nfunction checkDisplayField(view: Omit<ViewV2, \"id\" | \"version\">) {\n  if (view.primaryDisplay) {","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/views/index.ts#L242-L278","documentation":"checkReadonlyFields iterates the view's non-calculation schema fields and verifies each exists in the underlying table's schema. If a view references a field absent from table.schema, the view config is stale/invalid and a 400 HTTPError is thrown.","triggerScenarios":"create/update via guardViewSchema where view.schema contains a field name not present in table.schema — e.g. the column was deleted from the table but the view still references it, or the field name is misspelled.","commonSituations":"Deleting/renaming a table column while a view still lists it; importing view definitions from another app/table; case-sensitive name mismatch.","solutions":["Remove the stale field from the view schema.","Re-add the field to the table schema if it should exist.","Correct the field name spelling/casing in the view to match table.schema.","Recreate the view from the current table schema."],"exampleFix":"// before\nview.schema[\"nmae\"] = { visible: true, readonly: false }\n// after\nview.schema[\"name\"] = { visible: true, readonly: false } // matches table.schema","handlingStrategy":"validation","validationCode":"const valid = Object.keys(view.schema).filter(f => !helpers.views.isCalculationField(view.schema[f])).every(f => !!table.schema[f])\nif (!valid) throw new Error(\"view schema references unknown table fields\")","typeGuard":"function fieldsExistInTable(view: ViewV2, table: Table): boolean {\n  return Object.keys(view.schema).every(f => f in table.schema)\n}","tryCatchPattern":"try {\n  await sdk.views.update(view)\n} catch (e) {\n  if (e instanceof HTTPError && e.status === 400 && e.message.includes(\"is not valid for the requested table\")) {\n    const field = /Field \"(.+?)\"/.exec(e.message)?.[1]\n    if (field) delete view.schema[field]\n    await sdk.views.update(view)\n  } else { throw e }\n}","preventionTips":["Rebuild view schemas from the current table schema before updates","Remove view references when deleting/renaming table columns","Validate field names against table.schema after imports/migrations"],"tags":["validation","views","schema"],"backgroundTag":"field-not-in-schema","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}