{"record":{"id":"ee5c2790de70bae8","repo":"twentyhq/twenty","slug":"failed-to-backfill-record-page-s-for-workspace","errorCode":null,"errorMessage":"Failed to backfill record page(s) for workspace ${workspaceId}","messagePattern":"Failed to backfill record page\\(s\\) for workspace (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/twenty-server/src/database/commands/upgrade-version-command/2-31/2-31-workspace-command-1786437482000-backfill-record-page.command.ts","lineNumber":715,"sourceCode":"    >;\n  }): Promise<void> {\n    const result =\n      await this.workspaceMigrationValidateBuildAndRunService.validateBuildAndRunLegacyWorkspaceMigration(\n        {\n          isSystemBuild: true,\n          workspaceId,\n          applicationUniversalIdentifier,\n          allFlatEntityOperationByMetadataName:\n            allFlatEntityOperationByMetadataName as never,\n        },\n      );\n\n    if (result.status === 'fail') {\n      this.logger.error(\n        `Failed to backfill record page(s) for application ${applicationUniversalIdentifier} in workspace ${workspaceId}:\\n${JSON.stringify(result, null, 2)}`,\n      );\n\n      throw new Error(\n        `Failed to backfill record page(s) for workspace ${workspaceId}`,\n      );\n    }\n  }\n}\n","sourceCodeStart":697,"sourceCodeEnd":721,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-server/src/database/commands/upgrade-version-command/2-31/2-31-workspace-command-1786437482000-backfill-record-page.command.ts#L697-L721","documentation":"Thrown by the large 2.31 command that backfills record pages (views, view-fields, view-field-groups, page-layouts, tabs, widgets) per application. It builds allFlatEntityOperationByMetadataName and submits via validateBuildAndRunLegacyWorkspaceMigration; on status === 'fail' it logs the report (scoped to the applicationUniversalIdentifier) and throws. The report names which flat entity type and which entity failed.","triggerScenarios":"A referenced object/field/relation universal identifier is absent in the workspace; a view/page-layout universalIdentifier already exists with a conflicting shape; a system view key resolves to a layout whose dependencies are missing; the applicationUniversalIdentifier does not match a registered application for the workspace.","commonSituations":"Cross-version upgrade where intermediate commands that create the base objects/views were skipped; workspaces with heavily customised record pages that collide with the system layout being backfilled; stale workspace cache after an out-of-band metadata edit.","solutions":["Read the logged JSON report — note the metadata name (view/viewField/pageLayout/...), the entity universalIdentifier, and the error code.","For a missing-dependency error, ensure the prerequisite object/field exists (run the earlier upgrade commands first).","For a collision, remove or reconcile the conflicting existing entity for that workspace.","Invalidate and recompute the workspace cache, then re-run the 2.31 command for the workspace."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Per-application, assert referenced objects/views exist before building the batch:\nconst missing = requiredObjectUIs.filter(ui => !isDefined(flatObjectMetadataMaps.byUniversalIdentifier[ui]));\nif (missing.length > 0) { /* run prerequisite upgrades first */ }","typeGuard":null,"tryCatchPattern":"try {\n  await command.runOnWorkspace({ workspaceId, options });\n} catch (e) {\n  // e.message embeds the per-application report; parse and continue per-workspace\n  logger.error({ workspaceId, err: e.message }, 'record page backfill failed');\n}","preventionTips":["Run all earlier major-version upgrades first so base objects/views exist.","Invalidate the workspace cache before retrying so the build sees fresh metadata.","Parse the logged report to target the specific failing entity type."],"tags":["migration","upgrade-command","validate-and-build","workspace","record-page","page-layout","views","orchestrator"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}