twentyhq/twenty · error · Error
Failed to add coreWorkflowId field for workspace ${workspace
Error message
Failed to add coreWorkflowId field for workspace ${workspaceId} What it means
Thrown by the 2.23 command that adds the coreWorkflowId field, after the standard field was successfully resolved. The command calls validateBuildAndRunLegacyWorkspaceMigration with a fieldMetadata creation operation. If the legacy pipeline returns status 'fail', 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-23/2-23-workspace-command-1784286706000-add-workflow-core-soft-ref-field.command.ts:134
workspaceId,
applicationUniversalIdentifier:
twentyStandardFlatApplication.universalIdentifier,
allFlatEntityOperationByMetadataName: {
fieldMetadata: {
flatEntityToCreate: [flatFieldMetadataToCreate],
flatEntityToDelete: [],
flatEntityToUpdate: [],
},
},
},
);
if (result.status === 'fail') {
this.logger.error(
`Failed to add coreWorkflowId field:\n${JSON.stringify(result, null, 2)}`,
);
throw new Error(
`Failed to add coreWorkflowId field for workspace ${workspaceId}`,
);
}
this.logger.log(`Added coreWorkflowId field for workspace ${workspaceId}`);
}
}
View on GitHub (pinned to 1f5dd2bbd2)
Solutions
- Read the logger.error JSON output for the specific failure report
- Flush flatFieldMetadataMaps from workspace cache and retry — the command is idempotent
- Verify the workflow object exists in flatObjectMetadataMaps
- Run with --dryRun to confirm the operation shape
Defensive patterns
Strategy: retry
Validate before calling
// Before running, flush field metadata cache
await workspaceCacheService.invalidateAndRecompute(workspaceId, [
'flatFieldMetadataMaps',
'flatObjectMetadataMaps',
]);
// Confirm the workflow object exists
const { flatObjectMetadataMaps } = await workspaceCacheService.getOrRecompute(workspaceId, [
'flatObjectMetadataMaps',
]);
const hasWorkflow = isDefined(
flatObjectMetadataMaps.byUniversalIdentifier[STANDARD_OBJECTS.workflow.universalIdentifier]
);
if (!hasWorkflow) {
console.log('workflow 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 coreWorkflowId field')) {
await workspaceCacheService.flush(workspaceId, ['flatFieldMetadataMaps']);
await command.runOnWorkspace({ workspaceId, options: { dryRun: false } });
} else {
throw error;
}
} Prevention
- Run with --dryRun first to validate the operation shape
- Flush flatFieldMetadataMaps cache before retrying — the command is idempotent
- Parse the logger.error JSON for the specific validation failure
- Ensure no concurrent workspace metadata modifications
When it happens
Trigger: validateBuildAndRunLegacyWorkspaceMigration returns status 'fail' when creating the coreWorkflowId FlatFieldMetadata. Caused by: the workflow object not existing in workspace metadata at build time, a universal identifier collision, stale flatFieldMetadataMaps cache, or a DB error during column creation.
Common situations: Workspace cache reports the field as missing when it exists in the DB; a prior partial run created the DB column but not the metadata row; concurrent workspace modifications during upgrade.
Related errors
- Failed to add coreWorkflowVersionId field for workspace ${wo
- Standard application is missing workflowVersion field coreWo
- Standard application is missing workflow field coreWorkflowI
- Failed to add the messageCampaign name field for workspace $
- Failed to create searchVector GIN index(es) for workspace ${
AI-assisted analysis of twentyhq/twenty@1f5dd2bbd2 (2026-08-12).
Data as JSON: /api/errors/3dc31f9a8bdcbbc2.
Report an issue: GitHub.