{"record":{"id":"67a23bcc8c9a258e","repo":"twentyhq/twenty","slug":"failed-to-update-search-command-menu-item-labels-f","errorCode":null,"errorMessage":"Failed to update search command menu item labels for workspace ${workspaceId}","messagePattern":"Failed to update search command menu item labels for workspace (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-server/src/database/commands/upgrade-version-command/1-21/1-21-workspace-command-1775500015000-update-search-command-menu-item-labels.command.ts","lineNumber":130,"sourceCode":"          allFlatEntityOperationByMetadataName: {\n            commandMenuItem: {\n              flatEntityToCreate: [],\n              flatEntityToDelete: [],\n              flatEntityToUpdate: itemsToUpdate,\n            },\n          },\n          workspaceId,\n          applicationUniversalIdentifier:\n            twentyStandardFlatApplication.universalIdentifier,\n        },\n      );\n\n    if (validateAndBuildResult.status === 'fail') {\n      this.logger.error(\n        `Failed to update search labels:\\n${JSON.stringify(validateAndBuildResult, null, 2)}`,\n      );\n\n      throw new Error(\n        `Failed to update search command menu item labels for workspace ${workspaceId}`,\n      );\n    }\n\n    this.logger.log(\n      `Successfully updated ${itemsToUpdate.length} search command menu item label(s) for workspace ${workspaceId}`,\n    );\n  }\n}\n","sourceCodeStart":112,"sourceCodeEnd":140,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-server/src/database/commands/upgrade-version-command/1-21/1-21-workspace-command-1775500015000-update-search-command-menu-item-labels.command.ts#L112-L140","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Run the command in dry-run mode first; it logs planned itemsToUpdate without committing:\n//   npx nx run twenty-server:database:migrate:prod -- --dryRun\n// Programmatically, confirm the workspace cache is fresh before invoking:\nawait workspaceCacheService.invalidate(workspaceId);\nconst { flatCommandMenuItemMaps } = await workspaceCacheService.getOrRecompute(workspaceId, ['flatCommandMenuItemMaps']);\nconst hasSearchItems = [STANDARD_COMMAND_MENU_ITEMS.searchRecords.universalIdentifier, STANDARD_COMMAND_MENU_ITEMS.searchRecordsFallback.universalIdentifier]\n  .every((id) => isDefined(flatCommandMenuItemMaps.byUniversalIdentifier[id]));\nif (!hasSearchItems) throw new Error('Cache missing search command menu items; recompute before upgrade');","typeGuard":null,"tryCatchPattern":"// At the fleet runner level, isolate per-workspace failures so one bad workspace doesn't abort all:\ntry {\n  await command.runOnWorkspace({ workspaceId, options });\n} catch (err) {\n  logger.error(`Upgrade failed for workspace ${workspaceId}; continuing with others`, err);\n  failedWorkspaces.push(workspaceId);\n}","preventionTips":["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."],"tags":["migration","workspace-upgrade","command-menu-item","data-integrity"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}