{"record":{"id":"1f8d638ae394175f","repo":"twentyhq/twenty","slug":"failed-to-fix-merge-command-menu-item-expression-f","errorCode":null,"errorMessage":"Failed to fix merge command menu item expression for workspace ${workspaceId}","messagePattern":"Failed to fix merge command menu item expression for workspace (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-server/src/database/commands/upgrade-version-command/1-22/1-22-workspace-command-1780000003000-fix-merge-command-select-all.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 fix merge command expression:\\n${JSON.stringify(validateAndBuildResult, null, 2)}`,\n      );\n\n      throw new Error(\n        `Failed to fix merge command menu item expression for workspace ${workspaceId}`,\n      );\n    }\n\n    this.logger.log(\n      `Successfully updated ${itemsToUpdate.length} command menu item expression(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-22/1-22-workspace-command-1780000003000-fix-merge-command-select-all.command.ts#L112-L140","documentation":"Thrown by the 1.22 workspace upgrade command when validateBuildAndRunLegacyWorkspaceMigration returns 'fail' while fixing the 'select all' expression on the merge command menu item. The failure JSON is logged first, then the command aborts for that workspace.","triggerScenarios":"Running the merge-command select-all fix on a workspace where the merge command menu item is absent from cache, or the new expression fails the builder's expression validation.","commonSituations":"Workspace cache missing the merge command item so the update targets nothing; expression syntax rejected by the validator; partial prior upgrade left the item in an inconsistent state.","solutions":["Inspect the logged validateAndBuildResult JSON for the exact expression or lookup error.","Recompute the workspace cache and re-run.","Run --dryRun to confirm itemsToUpdate is non-empty and targets the merge command.","Isolate the failing workspace and reconcile its merge command metadata."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Dry-run and confirm the merge command menu item exists in cache before the real run:\nawait workspaceCacheService.invalidate(workspaceId);\nconst { flatCommandMenuItemMaps } = await workspaceCacheService.getOrRecompute(workspaceId, ['flatCommandMenuItemMaps']);\nif (!isDefined(flatCommandMenuItemMaps.byUniversalIdentifier[MERGE_COMMAND_ITEM_ID])) {\n  throw new Error('Merge command menu item missing; cannot patch select-all expression');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await command.runOnWorkspace({ workspaceId, options });\n} catch (err) {\n  logger.error(`Merge command expression fix failed for workspace ${workspaceId}`, err);\n  failedWorkspaces.push(workspaceId);\n}","preventionTips":["Run --dryRun to confirm the merge command item is the update target.","Recompute the cache so the item resolves correctly.","Validate the new expression syntax matches the builder's expected format.","Catch per-workspace at the runner."],"tags":["migration","workspace-upgrade","command-menu-item","expression"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}