twentyhq/twenty · error · Error
Failed to add the messageCampaign name field for workspace $
Error message
Failed to add the messageCampaign name field for workspace ${workspaceId} What it means
Thrown by the 2.25 command that adds the messageCampaign name field, after all standard entities were resolved. The command calls validateBuildAndRunLegacyWorkspaceMigration with a complex multi-entity operation: fieldMetadata creation, viewField creation, objectMetadata label-identifier update, and searchFieldMetadata creation. If the pipeline fails, the result is logged to logger.error and the generic error is thrown.
Source
Thrown at packages/twenty-server/src/database/commands/upgrade-version-command/2-25/2-25-workspace-command-1785229970000-add-message-campaign-name-field.command.ts:261
flatEntityToCreate: [],
flatEntityToDelete: [],
flatEntityToUpdate: flatObjectMetadataToUpdate,
},
searchFieldMetadata: {
flatEntityToCreate: searchFieldMetadatasToCreate,
flatEntityToDelete: [],
flatEntityToUpdate: [],
},
},
},
);
if (result.status === 'fail') {
this.logger.error(
`Failed to add the messageCampaign name field:\n${JSON.stringify(result, null, 2)}`,
);
throw new Error(
`Failed to add the messageCampaign name field for workspace ${workspaceId}`,
);
}
this.logger.log(
`Added the messageCampaign name field for workspace ${workspaceId}`,
);
}
// The standard positions assume a freshly provisioned view, where name comes
// first and everything else is shifted by one. Existing views keep subject at
// position 0, so name is placed relative to the columns already there: below
// all of them when it becomes the label identifier (the validator requires
// it), above all of them otherwise (the validator forbids anything below the
// label identifier).
private computeNameViewFieldPosition({
campaignIndexFlatView,
flatViewFieldMaps,View on GitHub (pinned to 1f5dd2bbd2)
Solutions
- Read the logger.error JSON output for the specific failure report
- Flush flatFieldMetadataMaps, flatViewFieldMaps, flatObjectMetadataMaps, flatSearchFieldMetadataMaps from workspace cache and retry
- Verify the computed name view field position satisfies the label-identifier constraint (label identifier must be strictly first)
- Run with --dryRun to inspect the operations
Defensive patterns
Strategy: retry
Validate before calling
// Before running, flush all relevant cache keys
await workspaceCacheService.invalidateAndRecompute(workspaceId, [
'flatObjectMetadataMaps',
'flatFieldMetadataMaps',
'flatViewMaps',
'flatViewFieldMaps',
'flatSearchFieldMetadataMaps',
]);
// Confirm the messageCampaign object exists
const { flatObjectMetadataMaps } = await workspaceCacheService.getOrRecompute(workspaceId, [
'flatObjectMetadataMaps',
]);
if (!isDefined(flatObjectMetadataMaps.byUniversalIdentifier[CAMPAIGN.universalIdentifier])) {
console.log('messageCampaign object does not exist — command will skip');
} Try / catch
// Retry once after flushing cache — the command is idempotent
try {
await command.runOnWorkspace({ workspaceId, options: { dryRun: false } });
} catch (error) {
if (error.message.includes('Failed to add the messageCampaign name field')) {
await workspaceCacheService.flush(workspaceId, [
'flatFieldMetadataMaps', 'flatViewFieldMaps', 'flatObjectMetadataMaps', 'flatSearchFieldMetadataMaps',
]);
await command.runOnWorkspace({ workspaceId, options: { dryRun: false } });
} else {
throw error;
}
} Prevention
- Run with --dryRun first — the command reports planned operation counts per entity type
- Flush all four cache keys (fieldMetadata, viewField, objectMetadata, searchFieldMetadata) before retrying
- Parse the logger.error JSON for the specific multi-entity validation failure
- Verify the computed name view field position satisfies the label-identifier constraint before committing
When it happens
Trigger: validateBuildAndRunLegacyWorkspaceMigration returns status 'fail' when applying the combined field/viewField/objectMetadata/searchFieldMetadata operations. Caused by: the label identifier update referencing a field that doesn't exist, view field position validation failure (the validator requires the label identifier at position 0), a universal identifier collision, stale cache, or a DB error.
Common situations: The name view field position computed by computeNameViewFieldPosition conflicts with the validator's label-identifier constraint; a prior partial run created some entities but not others; cache doesn't reflect actual metadata state.
Related errors
- Failed to add coreWorkflowVersionId field for workspace ${wo
- Failed to add coreWorkflowId field for workspace ${workspace
- Failed to align the message campaign record page for workspa
- Failed to configure message campaign command menu for worksp
- Standard application is missing the messageCampaign name fie
AI-assisted analysis of twentyhq/twenty@1f5dd2bbd2 (2026-08-12).
Data as JSON: /api/errors/153d0885258e6c21.
Report an issue: GitHub.