{"record":{"id":"77e0073654342e27","repo":"twentyhq/twenty","slug":"failed-to-delete-record-page-layout-entities-for-w","errorCode":null,"errorMessage":"Failed to delete record page layout entities for workspace ${workspaceId}","messagePattern":"Failed to delete record page layout entities for workspace (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-server/src/database/commands/upgrade-version-command/1-23/1-23-workspace-command-1780000001500-backfill-record-page-layouts.command.ts","lineNumber":230,"sourceCode":"              flatEntityToUpdate: [],\n            },\n            pageLayout: {\n              flatEntityToCreate: [],\n              flatEntityToDelete: recordPageLayouts,\n              flatEntityToUpdate: [],\n            },\n          },\n          workspaceId,\n          applicationUniversalIdentifier:\n            twentyStandardFlatApplication.universalIdentifier,\n        },\n      );\n\n    if (result.status === 'fail') {\n      this.logger.error(\n        `Failed to delete record page layout entities:\\n${JSON.stringify(result, null, 2)}`,\n      );\n      throw new Error(\n        `Failed to delete record page layout entities for workspace ${workspaceId}`,\n      );\n    }\n  }\n\n  private async createStandardRecordPageLayouts({\n    workspaceId,\n    twentyStandardFlatApplication,\n  }: {\n    workspaceId: string;\n    twentyStandardFlatApplication: FlatApplication;\n  }): Promise<void> {\n    const standardMaps =\n      computeTwentyStandardApplicationAllFlatEntityMapsPre231({\n        now: new Date().toISOString(),\n        workspaceId,\n        twentyStandardApplicationId: twentyStandardFlatApplication.id,\n      });","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-server/src/database/commands/upgrade-version-command/1-23/1-23-workspace-command-1780000001500-backfill-record-page-layouts.command.ts#L212-L248","documentation":"Thrown inside the 1.23 record-page-layout backfill command's delete step when validateBuildAndRunLegacyWorkspaceMigration returns 'fail' while deleting existing record page layout entities. The full result JSON is logged before throwing to surface the deletion rejection.","triggerScenarios":"Running the 1.23 backfill on a workspace whose record-page-layout entities are referenced by other metadata the validator won't let cascade-delete, or where the delete batch references identifiers absent from the workspace.","commonSituations":"Layout entities still referenced by views/sections blocking deletion; stale cache so the delete set is wrong; a previous partial run left orphaned references.","solutions":["Read the logged result JSON to see which delete operation was rejected and why.","Recompute the workspace cache and retry so the layout entity set is current.","Run --dryRun to inspect the planned delete set.","Manually reconcile dangling references in the failing workspace before re-running."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Dry-run to inspect the planned delete set, and confirm no dangling references block deletion:\nawait workspaceCacheService.invalidate(workspaceId);\nconst { flatRecordPageLayoutMaps } = await workspaceCacheService.getOrRecompute(workspaceId, ['flatRecordPageLayoutMaps']);\nconst referenced = await checkLayoutReferences(workspaceId, flatRecordPageLayoutMaps);\nif (referenced.length > 0) throw new Error('Some layouts still referenced; cannot delete safely');","typeGuard":null,"tryCatchPattern":"try {\n  await command.runOnWorkspace({ workspaceId, options });\n} catch (err) {\n  logger.error(`Record page layout delete failed for workspace ${workspaceId}`, err);\n  failedWorkspaces.push(workspaceId);\n}","preventionTips":["Run --dryRun to review the delete set.","Recompute the cache before running so the delete set is accurate.","Check for views/sections still referencing layouts before deleting.","Isolate per-workspace failures at the runner."],"tags":["migration","workspace-upgrade","record-page-layout","delete"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}