{"record":{"id":"ae82871117cdb8af","repo":"twentyhq/twenty","slug":"failed-to-update-edit-command-availability-express","errorCode":null,"errorMessage":"Failed to update Edit command availability expressions for workspace ${workspaceId}","messagePattern":"Failed to update Edit command availability expressions for workspace (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-server/src/database/commands/upgrade-version-command/2-1/2-1-workspace-command-1795000001000-add-layout-customization-guard-to-edit-commands.command.ts","lineNumber":171,"sourceCode":"          allFlatEntityOperationByMetadataName: {\n            commandMenuItem: {\n              flatEntityToCreate: [],\n              flatEntityToDelete: [],\n              flatEntityToUpdate: itemsToUpdate,\n            },\n          },\n          workspaceId,\n          applicationUniversalIdentifier:\n            workspaceCustomFlatApplication.universalIdentifier,\n        },\n      );\n\n    if (validateAndBuildResult.status === 'fail') {\n      this.logger.error(\n        `Failed to update Edit command availability expressions:\\n${JSON.stringify(validateAndBuildResult, null, 2)}`,\n      );\n\n      throw new Error(\n        `Failed to update Edit command availability expressions for workspace ${workspaceId}`,\n      );\n    }\n\n    this.logger.log(\n      `Successfully updated ${itemsToUpdate.length} Edit command availability expression(s) for workspace ${workspaceId}`,\n    );\n  }\n}\n","sourceCodeStart":153,"sourceCodeEnd":181,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-server/src/database/commands/upgrade-version-command/2-1/2-1-workspace-command-1795000001000-add-layout-customization-guard-to-edit-commands.command.ts#L153-L181","documentation":"Thrown by the 2.1 workspace upgrade command when validateBuildAndRunLegacyWorkspaceMigration returns 'fail' while adding a layout-customization guard to Edit command availability expressions. Notably this command scopes the migration to the workspace's CUSTOM flat application (workspaceCustomFlatApplication.universalIdentifier), not the twenty-standard one, so failures often relate to custom-app Edit commands.","triggerScenarios":"Running the 2.1 Edit-command guard update on a workspace whose custom-application Edit commands are absent from cache, or whose new guard expression the builder rejects.","commonSituations":"Stale cache missing the custom-app Edit commands; the layout-customization permission flag referenced by the guard isn't registered; the workspace has no custom application, making the custom-app scope invalid.","solutions":["Inspect the logged validateAndBuildResult JSON for the rejected expression or missing custom-app command.","Confirm the workspace actually has a custom flat application (the command assumes one exists).","Recompute the workspace cache and re-run.","Run --dryRun to confirm itemsToUpdate is scoped to the custom application."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// This command scopes to the CUSTOM application; confirm it exists and its Edit commands are cached:\nawait workspaceCacheService.invalidate(workspaceId);\nconst { twentyStandardFlatApplication, workspaceCustomFlatApplication } =\n  await applicationService.findWorkspaceTwentyStandardAndCustomApplicationOrThrow({ workspaceId });\nif (!isDefined(workspaceCustomFlatApplication)) throw new Error('Workspace has no custom application; Edit-command guard cannot apply');\nconst { flatCommandMenuItemMaps } = await workspaceCacheService.getOrRecompute(workspaceId, ['flatCommandMenuItemMaps']);\nconst editItems = Object.values(flatCommandMenuItemMaps.byUniversalIdentifier).filter((i) => isDefined(i) && i.applicationUniversalIdentifier === workspaceCustomFlatApplication.universalIdentifier && isEditCommand(i));\nif (editItems.length === 0) throw new Error('No custom-app Edit commands found to guard');","typeGuard":null,"tryCatchPattern":"try {\n  await command.runOnWorkspace({ workspaceId, options });\n} catch (err) {\n  logger.error(`Edit command guard update failed for workspace ${workspaceId}`, err);\n  failedWorkspaces.push(workspaceId);\n}","preventionTips":["Confirm the workspace actually has a custom flat application before running.","Run --dryRun to confirm itemsToUpdate is scoped to the custom application.","Verify the layout-customization permission flag is registered in the build.","Recompute the cache before running; catch per-workspace at the runner."],"tags":["migration","workspace-upgrade","command-menu-item","custom-application","permissions"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}