{"record":{"id":"5920b4758fa2d6c4","repo":"twentyhq/twenty","slug":"failed-to-update-command-menu-item-availability-ty","errorCode":null,"errorMessage":"Failed to update command menu item availability types for workspace ${workspaceId}","messagePattern":"Failed to update command menu item availability types for workspace (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-server/src/database/commands/upgrade-version-command/1-23/1-23-workspace-command-1780000005000-update-global-object-context-command-menu-items.command.ts","lineNumber":133,"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 command menu item availability types:\\n${JSON.stringify(validateAndBuildResult, null, 2)}`,\n      );\n\n      throw new Error(\n        `Failed to update command menu item availability types for workspace ${workspaceId}`,\n      );\n    }\n\n    this.logger.log(\n      `Successfully updated ${itemsToUpdate.length} command menu item availability type(s) for workspace ${workspaceId}`,\n    );\n  }\n}\n","sourceCodeStart":115,"sourceCodeEnd":143,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-server/src/database/commands/upgrade-version-command/1-23/1-23-workspace-command-1780000005000-update-global-object-context-command-menu-items.command.ts#L115-L143","documentation":"Thrown by the 1.23 workspace upgrade command when validateBuildAndRunLegacyWorkspaceMigration returns 'fail' while updating availability types on global/object-context command menu items. The full validateAndBuildResult JSON is logged before the throw.","triggerScenarios":"Running the 1.23 availability-type update on a workspace whose command menu items are absent from cache, or whose new availabilityType values the builder rejects (invalid enum, incompatible with the item's context).","commonSituations":"Stale cache returning undefined items; availability type value not in the allowed set for that build; partial prior upgrade left items mid-change.","solutions":["Inspect the logged validateAndBuildResult JSON for the rejected availability type or missing item.","Recompute the workspace cache and re-run.","Run --dryRun to confirm itemsToUpdate targets the expected global/object-context items.","Isolate and reconcile the failing workspace's command menu items."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Dry-run to preview availability-type changes, and confirm target items exist in cache:\nawait workspaceCacheService.invalidate(workspaceId);\nconst { flatCommandMenuItemMaps } = await workspaceCacheService.getOrRecompute(workspaceId, ['flatCommandMenuItemMaps']);\nconst targetsExist = TARGET_ITEM_IDS.every((id) => isDefined(flatCommandMenuItemMaps.byUniversalIdentifier[id]));\nif (!targetsExist) throw new Error('Target command menu items missing; cannot update availability types');","typeGuard":null,"tryCatchPattern":"try {\n  await command.runOnWorkspace({ workspaceId, options });\n} catch (err) {\n  logger.error(`Availability type update failed for workspace ${workspaceId}`, err);\n  failedWorkspaces.push(workspaceId);\n}","preventionTips":["Run --dryRun to confirm itemsToUpdate targets the expected global/object-context items.","Validate the new availabilityType values are in the allowed enum set for the build.","Recompute the cache before running.","Catch per-workspace at the runner."],"tags":["migration","workspace-upgrade","command-menu-item","availability"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}