{"record":{"id":"80f6d90fcc2e83da","repo":"twentyhq/twenty","slug":"failed-to-sync-command-menu-item-availability-expr-80f6d9","errorCode":null,"errorMessage":"Failed to sync command menu item availability expressions for workspace ${workspaceId}","messagePattern":"Failed to sync command menu item availability expressions for workspace (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-server/src/database/commands/upgrade-version-command/2-7/2-7-workspace-command-1798000020000-sync-command-menu-item-availability-expressions.command.ts","lineNumber":124,"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 sync command menu item availability expressions:\\n${JSON.stringify(validateAndBuildResult, null, 2)}`,\n      );\n\n      throw new Error(\n        `Failed to sync command menu item availability expressions for workspace ${workspaceId}`,\n      );\n    }\n\n    this.logger.log(\n      `Successfully synced ${itemsToUpdate.length} command menu item availability expression(s) for workspace ${workspaceId}`,\n    );\n  }\n}\n","sourceCodeStart":106,"sourceCodeEnd":134,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-server/src/database/commands/upgrade-version-command/2-7/2-7-workspace-command-1798000020000-sync-command-menu-item-availability-expressions.command.ts#L106-L134","documentation":"Thrown by the 2.7 command that syncs command menu item availability expressions. It updates a batch of command menu items via validateBuildAndRunLegacyWorkspaceMigration; on status === 'fail' it logs the report and throws. The report identifies which command menu item(s) failed the availability-expression validation.","triggerScenarios":"An availability expression references a field/object/relation that was renamed or removed; a command menu item universalIdentifier in the update batch no longer exists in the workspace; the expression string fails the expression-validator (syntax error, unknown function).","commonSituations":"Cross-version upgrade where referenced fields were renamed in an intermediate release; workspace with custom command menu items whose identifiers drifted; malformed expression left by a prior partial run.","solutions":["Read the logged JSON report to find the failing item and whether it is a missing-entity or expression-syntax error.","For a missing entity, seed or rename-restore it; for an invalid expression, correct or clear the stored expression for that item.","Re-run the 2.7 command for the workspace."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate each availability expression's referenced identifiers exist before syncing:\nfor (const item of itemsToUpdate) {\n  const refs = extractExpressionRefs(item.availabilityExpression);\n  const missing = refs.filter(r => !isDefined(flatObjectMetadataMaps.byUniversalIdentifier[r]));\n  if (missing.length > 0) { /* repair expression first */ }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await command.runOnWorkspace({ workspaceId, options });\n} catch (e) {\n  logger.error({ workspaceId, err: e.message }, 'command menu availability sync failed');\n}","preventionTips":["Run prerequisite upgrades that rename/seed referenced objects before syncing expressions.","On failure, read the logged report to find the invalid expression."],"tags":["migration","upgrade-command","validate-and-build","workspace","command-menu-item","availability-expression"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}