{"record":{"id":"1ac8888043a1deed","repo":"twentyhq/twenty","slug":"failed-to-align-the-message-campaign-record-page-f","errorCode":null,"errorMessage":"Failed to align the message campaign record page for workspace ${workspaceId}: ${JSON.stringify(validateAndBuildResult, null, 2)}","messagePattern":"Failed to align the message campaign record page for workspace (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-server/src/database/commands/upgrade-version-command/2-25/2-25-workspace-command-1785229940000-add-message-campaign-composer-tab.command.ts","lineNumber":327,"sourceCode":"              flatEntityToDelete: [],\n              flatEntityToUpdate: [],\n            },\n            viewField: {\n              flatEntityToCreate: viewFieldsToCreate,\n              flatEntityToDelete: [],\n              flatEntityToUpdate: [],\n            },\n            viewFieldGroup: {\n              flatEntityToCreate: viewFieldGroupsToCreate,\n              flatEntityToDelete: [],\n              flatEntityToUpdate: [],\n            },\n          },\n        },\n      );\n\n    if (validateAndBuildResult.status === 'fail') {\n      throw new Error(\n        `Failed to align the message campaign record page for workspace ${workspaceId}: ${JSON.stringify(\n          validateAndBuildResult,\n          null,\n          2,\n        )}`,\n      );\n    }\n\n    this.logger.log(\n      `Aligned the message campaign record page for workspace ${workspaceId}`,\n    );\n  }\n}\n","sourceCodeStart":309,"sourceCodeEnd":341,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-server/src/database/commands/upgrade-version-command/2-25/2-25-workspace-command-1785229940000-add-message-campaign-composer-tab.command.ts#L309-L341","documentation":"Thrown by the 2.25 command that aligns the message campaign record page to a home Fields tab plus an Email composer tab. After computing all create/update/delete operations across pageLayoutTab, pageLayoutWidget, view, viewField, and viewFieldGroup, the command calls validateBuildAndRunLegacyWorkspaceMigration. If the pipeline fails, the error is thrown WITH the full validateAndBuildResult JSON inlined in the message (unlike other commands that only log it separately).","triggerScenarios":"validateBuildAndBuildLegacyWorkspaceMigration returns status 'fail' when applying the multi-entity record-page alignment operations. Caused by: a referenced standard page-layout tab/widget/view/viewField/viewFieldGroup not existing in the workspace, a universal identifier collision, position/constraint validation rejection, stale cache, or a DB error.","commonSituations":"Workspace predates the message campaign record page entirely (page layout doesn't exist — but this is guarded by an early return); the composer tab was partially created by a prior failed run; cache doesn't reflect actual DB state.","solutions":["The thrown error message itself contains JSON.stringify(validateAndBuildResult, null, 2) — parse it for the exact failure report","Flush flatPageLayoutMaps, flatPageLayoutTabMaps, flatPageLayoutWidgetMaps, flatViewMaps, flatViewFieldMaps, flatViewFieldGroupMaps from workspace cache and retry","Verify all referenced standard universal identifiers resolve via getStandardFlatEntitiesToCreateOrThrow (which throws earlier if a standard entity is missing)","Run with --dryRun to inspect the operations"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Before running, flush all relevant cache keys\nawait workspaceCacheService.invalidateAndRecompute(workspaceId, [\n  'flatPageLayoutMaps',\n  'flatPageLayoutTabMaps',\n  'flatPageLayoutWidgetMaps',\n  'flatViewMaps',\n  'flatViewFieldMaps',\n  'flatViewFieldGroupMaps',\n]);\n\n// Confirm the message campaign page layout exists (the command guards on this)\nconst { flatPageLayoutMaps } = await workspaceCacheService.getOrRecompute(workspaceId, [\n  'flatPageLayoutMaps',\n]);\n\nconst hasLayout = isDefined(\n  flatPageLayoutMaps.byUniversalIdentifier[MESSAGE_CAMPAIGN_PAGE_LAYOUT_UID]\n);\n\nif (!hasLayout) {\n  console.log('Message campaign page layout does not exist — command will skip');\n}","typeGuard":null,"tryCatchPattern":"// The thrown error includes the full JSON — parse it to distinguish retryable failures\ntry {\n  await command.runOnWorkspace({ workspaceId, options: { dryRun: false } });\n} catch (error) {\n  // The error message embeds the validateAndBuildResult JSON\n  const isValidationFailure = error.message.includes('\"status\": \"fail\"');\n  if (isValidationFailure) {\n    await workspaceCacheService.flush(workspaceId, [\n      'flatPageLayoutMaps', 'flatPageLayoutTabMaps', 'flatPageLayoutWidgetMaps',\n    ]);\n    await command.runOnWorkspace({ workspaceId, options: { dryRun: false } });\n  } else {\n    throw error;\n  }\n}","preventionTips":["The thrown error message embeds JSON.stringify(validateAndBuildResult) — always parse it for the exact failure report","Run with --dryRun first to inspect the multi-entity operation shape","Flush all six cache keys (pageLayout, tab, widget, view, viewField, viewFieldGroup) before retrying","Ensure getStandardFlatEntitiesToCreateOrThrow resolves all standard identifiers before the main migration call"],"tags":["metadata","upgrade-command","workspace-migration","validate-build-run","page-layout","message-campaign"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}