twentyhq/twenty · error · Error
Failed to update search command menu item labels for workspa
Error message
Failed to update search command menu item labels for workspace ${workspaceId} What it means
Thrown by the 1.21 workspace upgrade command after WorkspaceMigrationValidateBuildAndRunService.validateBuildAndRunLegacyWorkspaceMigration returns status 'fail' while updating labels of the searchRecords and searchRecordsFallback command menu items. The command logs the full validateAndBuildResult JSON first, then aborts so the failure is visible instead of silently skipped.
Source
Thrown at packages/twenty-server/src/database/commands/upgrade-version-command/1-21/1-21-workspace-command-1775500015000-update-search-command-menu-item-labels.command.ts:130
allFlatEntityOperationByMetadataName: {
commandMenuItem: {
flatEntityToCreate: [],
flatEntityToDelete: [],
flatEntityToUpdate: itemsToUpdate,
},
},
workspaceId,
applicationUniversalIdentifier:
twentyStandardFlatApplication.universalIdentifier,
},
);
if (validateAndBuildResult.status === 'fail') {
this.logger.error(
`Failed to update search labels:\n${JSON.stringify(validateAndBuildResult, null, 2)}`,
);
throw new Error(
`Failed to update search command menu item labels for workspace ${workspaceId}`,
);
}
this.logger.log(
`Successfully updated ${itemsToUpdate.length} search command menu item label(s) for workspace ${workspaceId}`,
);
}
}
View on GitHub (pinned to 1f5dd2bbd2)
Solutions
- Read the logged validateAndBuildResult JSON directly above the throw; it contains the exact validation rejection reason.
- Invalidate and recompute the workspace cache (workspaceCacheService.getOrRecompute) for the failing workspace, then re-run.
- Run with --dryRun to confirm which items would change before committing.
- Re-run the command scoped to the single failing workspace to isolate it from the fleet.
Defensive patterns
Strategy: validation
Validate before calling
// Run the command in dry-run mode first; it logs planned itemsToUpdate without committing:
// npx nx run twenty-server:database:migrate:prod -- --dryRun
// Programmatically, confirm the workspace cache is fresh before invoking:
await workspaceCacheService.invalidate(workspaceId);
const { flatCommandMenuItemMaps } = await workspaceCacheService.getOrRecompute(workspaceId, ['flatCommandMenuItemMaps']);
const hasSearchItems = [STANDARD_COMMAND_MENU_ITEMS.searchRecords.universalIdentifier, STANDARD_COMMAND_MENU_ITEMS.searchRecordsFallback.universalIdentifier]
.every((id) => isDefined(flatCommandMenuItemMaps.byUniversalIdentifier[id]));
if (!hasSearchItems) throw new Error('Cache missing search command menu items; recompute before upgrade'); Try / catch
// At the fleet runner level, isolate per-workspace failures so one bad workspace doesn't abort all:
try {
await command.runOnWorkspace({ workspaceId, options });
} catch (err) {
logger.error(`Upgrade failed for workspace ${workspaceId}; continuing with others`, err);
failedWorkspaces.push(workspaceId);
} Prevention
- Always run new upgrade commands with --dryRun against a representative workspace first.
- Invalidate and recompute the workspace cache before running metadata-touching upgrades.
- Wrap per-workspace execution in try/catch at the runner so a single failure doesn't stop the fleet.
- Read the logged validateAndBuildResult JSON before retrying; never retry unchanged.
When it happens
Trigger: Running upgrade:1-21:update-search-command-menu-item-labels (or a bundled migrate:prod that includes it) on a workspace whose cached command-menu items are missing the two search items, or whose flat-entity update the migration builder rejects.
Common situations: Stale workspace cache returning undefined for the search menu items; a prior partial upgrade left the workspace mid-1.21; standard command menu item universal identifiers drifted between the installed build and the workspace's stored metadata.
Related errors
- Failed to add Send Email record-selection commands for works
- 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/67a23bcc8c9a258e.
Report an issue: GitHub.