twentyhq/twenty · error · Error
Failed to add Send Email record-selection commands for works
Error message
Failed to add Send Email record-selection commands for workspace ${workspaceId} What it means
Thrown by the 1.22 workspace upgrade command when validateBuildAndRunLegacyWorkspaceMigration returns status 'fail' during creation of the new 'Send Email' record-selection command menu items. The detailed failure payload is logged before the throw so the operator can see why the build rejected the create operations.
Source
Thrown at packages/twenty-server/src/database/commands/upgrade-version-command/1-22/1-22-workspace-command-1775500016000-add-send-email-record-selection-command-menu-items.command.ts:126
allFlatEntityOperationByMetadataName: {
commandMenuItem: {
flatEntityToCreate: itemsToCreate,
flatEntityToDelete: [],
flatEntityToUpdate: [],
},
},
workspaceId,
applicationUniversalIdentifier:
twentyStandardFlatApplication.universalIdentifier,
},
);
if (validateAndBuildResult.status === 'fail') {
this.logger.error(
`Failed to add Send Email record-selection commands:\n${JSON.stringify(validateAndBuildResult, null, 2)}`,
);
throw new Error(
`Failed to add Send Email record-selection commands for workspace ${workspaceId}`,
);
}
this.logger.log(
`Successfully added ${itemsToCreate.length} Send Email record-selection commands for workspace ${workspaceId}`,
);
}
}
View on GitHub (pinned to 1f5dd2bbd2)
Solutions
- Inspect the logged validateAndBuildResult JSON for the specific create rejection (duplicate identifier, missing parent, etc.).
- Recompute the workspace cache and re-run so the existing-items diff is accurate.
- Run --dryRun first to see the planned itemsToCreate.
- Scope the upgrade to the failing workspace and resolve the flagged metadata before continuing the fleet.
Defensive patterns
Strategy: validation
Validate before calling
// Dry-run to preview itemsToCreate, and confirm the parent Send Email command exists:
await workspaceCacheService.invalidate(workspaceId);
const { flatCommandMenuItemMaps } = await workspaceCacheService.getOrRecompute(workspaceId, ['flatCommandMenuItemMaps']);
const parentExists = isDefined(flatCommandMenuItemMaps.byUniversalIdentifier[SEND_EMAIL_COMMAND_ID]);
if (!parentExists) throw new Error('Parent Send Email command missing; cannot attach record-selection items'); Try / catch
try {
await command.runOnWorkspace({ workspaceId, options });
} catch (err) {
logger.error(`Send Email item creation failed for workspace ${workspaceId}`, err);
failedWorkspaces.push(workspaceId);
} Prevention
- Run --dryRun to verify itemsToCreate before committing.
- Ensure the parent command the new items attach to exists in the workspace cache.
- Recompute the cache before running; stale caches cause phantom missing-parent failures.
- Catch per-workspace at the runner to keep the fleet moving.
When it happens
Trigger: Running the 1.22 Send Email record-selection command-menu-item creation on a workspace where the referenced parent command or object metadata is absent, or where the new items duplicate existing universal identifiers / keys the validator forbids.
Common situations: Workspace cache lacks the Send Email command the items attach to; a previous run partially created the items leaving duplicates; standard application flat-entity maps out of sync with the workspace's stored application.
Related errors
- Failed to update search command menu item labels for workspa
- Failed to fix merge command menu item expression for workspa
- Failed to update command menu item availability types for wo
- Failed to gate export/import command menu items by permissio
- Failed to update Edit command availability expressions for w
AI-assisted analysis of twentyhq/twenty@1f5dd2bbd2 (2026-08-12).
Data as JSON: /api/errors/321097cdfc763590.
Report an issue: GitHub.