{"record":{"id":"02b00b57900593cd","repo":"Budibase/budibase","slug":"field-field-must-be-visible-if-you-want-to-ma","errorCode":null,"errorMessage":"Field \"${field}\" must be visible if you want to make it readonly","messagePattern":"Field \"(.+?)\" must be visible if you want to make it readonly","errorType":"validation","errorClass":"HTTPError","httpStatus":400,"severity":"error","filePath":"packages/server/src/sdk/workspace/views/index.ts","lineNumber":268,"sourceCode":") {\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) {\n    const viewSchemaField = view.schema?.[view.primaryDisplay]\n\n    if (!viewSchemaField?.visible) {\n      throw new HTTPError(\n        `You can't hide \"${view.primaryDisplay}\" because it is the display column.`,\n        400\n      )\n    }","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/views/index.ts#L250-L286","documentation":"checkReadonlyFields enforces that a view field marked readonly must also be visible. A hidden-but-readonly field is contradictory config (nothing renders to be readonly), so a 400 HTTPError is thrown.","triggerScenarios":"create/update via guardViewSchema where for some field viewSchema[field].readonly === true and viewSchema[field].visible !== true (undefined/false).","commonSituations":"Toggling visible=false in the UI while readonly stays true; hand-built view payloads; migration scripts that set visible flags without checking readonly.","solutions":["Set visible: true for the readonly field in the view schema.","Or set readonly: false if the field should be hidden.","Audit the view schema so visible and readonly flags are consistent."],"exampleFix":"// before\nview.schema[\"email\"] = { visible: false, readonly: true }\n// after\nview.schema[\"email\"] = { visible: true, readonly: true }","handlingStrategy":"validation","validationCode":"for (const [f, s] of Object.entries(view.schema ?? {})) {\n  if (s.readonly && !s.visible) throw new Error(`${f} readonly but hidden`)\n}","typeGuard":"function readonlyFieldsVisible(view: ViewV2): boolean {\n  return Object.values(view.schema ?? {}).every(s => !s.readonly || s.visible === true)\n}","tryCatchPattern":"try {\n  await sdk.views.update(view)\n} catch (e) {\n  if (e instanceof HTTPError && e.status === 400 && e.message.includes(\"must be visible if you want to make it readonly\")) {\n    // set visible:true on offending fields, then retry\n  } else { throw e }\n}","preventionTips":["Treat visible and readonly as coupled: readonly implies visible","When toggling visible=false, also clear readonly","Validate the schema payload in UI before submit"],"tags":["validation","views","schema"],"backgroundTag":"invalid-view-configuration","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}