{"record":{"id":"a7b239f031e07773","repo":"twentyhq/twenty","slug":"failed-to-align-the-all-campaigns-view-columns-for","errorCode":null,"errorMessage":"Failed to align the all campaigns view columns for workspace ${workspaceId}","messagePattern":"Failed to align the all campaigns view columns 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-1785332560000-align-message-campaign-view-field-positions.command.ts","lineNumber":185,"sourceCode":"          isSystemBuild: true,\n          workspaceId,\n          applicationUniversalIdentifier,\n          allFlatEntityOperationByMetadataName: {\n            viewField: {\n              flatEntityToCreate: [],\n              flatEntityToDelete: [],\n              flatEntityToUpdate: viewFieldsToUpdate,\n            },\n          },\n        },\n      );\n\n    if (result.status === 'fail') {\n      this.logger.error(\n        `Failed to align the all campaigns view columns:\\n${JSON.stringify(result, null, 2)}`,\n      );\n\n      throw new Error(\n        `Failed to align the all campaigns view columns for workspace ${workspaceId}`,\n      );\n    }\n  }\n}\n","sourceCodeStart":167,"sourceCodeEnd":191,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-server/src/database/commands/upgrade-version-command/2-25/2-25-workspace-command-1785332560000-align-message-campaign-view-field-positions.command.ts#L167-L191","documentation":"Thrown by the 2.25 command that aligns all campaigns view column positions with the standard layout. The command computes position updates via computeViewFieldPositionsAlignedToStandard, splits them into two batches (others and lowest — the lowest-position update runs separately to avoid position conflicts), and calls validateBuildAndRunLegacyWorkspaceMigration for each batch with viewField update operations. If either batch fails, the result is logged to logger.error and the generic error is thrown.","triggerScenarios":"validateBuildAndRunLegacyWorkspaceMigration returns status 'fail' when updating viewField positions. Caused by: position validation rejecting the new values (e.g., the label identifier must remain strictly first), a viewField universal identifier not existing in the workspace, stale flatViewFieldMaps cache, or a DB error.","commonSituations":"The computed positions don't satisfy the validator's ordering constraints (particularly the label-identifier-must-be-first rule); a prior run partially updated positions leaving gaps or conflicts; cache is stale.","solutions":["Read the logger.error JSON output for the specific failure report","Flush flatViewMaps and flatViewFieldMaps from workspace cache and retry — the command is idempotent","Verify the label identifier view field would remain at the lowest position after the update","Run with --dryRun to inspect the planned position changes"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Before running, flush view and view field cache\nawait workspaceCacheService.invalidateAndRecompute(workspaceId, [\n  'flatViewMaps',\n  'flatViewFieldMaps',\n]);\n\n// Confirm the all campaigns view exists\nconst { flatViewMaps } = await workspaceCacheService.getOrRecompute(workspaceId, [\n  'flatViewMaps',\n]);\n\nif (!isDefined(flatViewMaps.byUniversalIdentifier[ALL_CAMPAIGNS_VIEW_UID])) {\n  console.log('All campaigns view does not exist — command will skip');\n}","typeGuard":null,"tryCatchPattern":"// Retry once after flushing cache — the command is idempotent\n// Note: the command splits updates into two batches (others, lowest)\ntry {\n  await command.runOnWorkspace({ workspaceId, options: { dryRun: false } });\n} catch (error) {\n  if (error.message.includes('Failed to align the all campaigns view columns')) {\n    await workspaceCacheService.flush(workspaceId, ['flatViewMaps', 'flatViewFieldMaps']);\n    await command.runOnWorkspace({ workspaceId, options: { dryRun: false } });\n  } else {\n    throw error;\n  }\n}","preventionTips":["Run with --dryRun first to inspect the planned position changes","Flush flatViewMaps and flatViewFieldMaps cache before retrying","Parse the logger.error JSON for the specific viewField position validation failure","Verify the label identifier view field remains at the strictly-lowest position after alignment"],"tags":["metadata","upgrade-command","workspace-migration","validate-build-run","flat-view-field","message-campaign"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}