{"record":{"id":"2e099c23d02061c4","repo":"twentyhq/twenty","slug":"failed-to-sync-command-menu-item-availability-expr","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-13/2-13-workspace-command-1781277470000-sync-create-record-command-availability-expression.command.ts","lineNumber":127,"sourceCode":"              flatEntityToDelete: [],\n              flatEntityToUpdate: itemsToUpdate,\n            },\n          },\n          workspaceId,\n          // Standard command menu items are system-owned; without a system\n          // build the validator rejects direct updates.\n          isSystemBuild: true,\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":109,"sourceCodeEnd":137,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-server/src/database/commands/upgrade-version-command/2-13/2-13-workspace-command-1781277470000-sync-create-record-command-availability-expression.command.ts#L109-L137","documentation":"Thrown by the 2.13 workspace upgrade command when validateBuildAndRunLegacyWorkspaceMigration returns 'fail' while syncing the availability expression of the create-record command menu items (run with isSystemBuild:true against the twenty-standard application). The full validateAndBuildResult JSON is logged before the throw.","triggerScenarios":"Running the 2.13 create-record availability-expression sync on a workspace whose create-record command menu items are missing from cache, or whose new availability expression the builder's expression validator rejects.","commonSituations":"Stale cache so create-record items resolve to undefined; expression references a field/object not present in the workspace; partial prior run left items inconsistent; standard application version mismatch.","solutions":["Read the logged validateAndBuildResult JSON for the exact expression or lookup error.","Recompute the workspace cache and re-run.","Run --dryRun to confirm itemsToUpdate targets the create-record items.","Verify the expression's referenced entities exist in the failing workspace."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Dry-run to preview availability-expression changes, and confirm create-record items exist in cache:\nawait workspaceCacheService.invalidate(workspaceId);\nconst { flatCommandMenuItemMaps } = await workspaceCacheService.getOrRecompute(workspaceId, ['flatCommandMenuItemMaps']);\nconst createItems = Object.values(flatCommandMenuItemMaps.byUniversalIdentifier).filter((i) => isDefined(i) && isCreateRecordCommand(i));\nif (createItems.length === 0) throw new Error('No create-record command menu items found to sync');","typeGuard":null,"tryCatchPattern":"try {\n  await command.runOnWorkspace({ workspaceId, options });\n} catch (err) {\n  logger.error(`Create-record availability sync failed for workspace ${workspaceId}`, err);\n  failedWorkspaces.push(workspaceId);\n}","preventionTips":["Run --dryRun to confirm itemsToUpdate targets create-record items.","Verify any field/object referenced by the new expression exists in the workspace.","Recompute the cache before running.","Catch per-workspace at the runner."],"tags":["migration","workspace-upgrade","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"}