twentyhq/twenty · error · Error
Failed to update Edit command availability expressions for w
Error message
Failed to update Edit command availability expressions for workspace ${workspaceId} What it means
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.
Source
Thrown at 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:171
allFlatEntityOperationByMetadataName: {
commandMenuItem: {
flatEntityToCreate: [],
flatEntityToDelete: [],
flatEntityToUpdate: itemsToUpdate,
},
},
workspaceId,
applicationUniversalIdentifier:
workspaceCustomFlatApplication.universalIdentifier,
},
);
if (validateAndBuildResult.status === 'fail') {
this.logger.error(
`Failed to update Edit command availability expressions:\n${JSON.stringify(validateAndBuildResult, null, 2)}`,
);
throw new Error(
`Failed to update Edit command availability expressions for workspace ${workspaceId}`,
);
}
this.logger.log(
`Successfully updated ${itemsToUpdate.length} Edit command availability expression(s) for workspace ${workspaceId}`,
);
}
}
View on GitHub (pinned to 1f5dd2bbd2)
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.
Defensive patterns
Strategy: validation
Validate before calling
// This command scopes to the CUSTOM application; confirm it exists and its Edit commands are cached:
await workspaceCacheService.invalidate(workspaceId);
const { twentyStandardFlatApplication, workspaceCustomFlatApplication } =
await applicationService.findWorkspaceTwentyStandardAndCustomApplicationOrThrow({ workspaceId });
if (!isDefined(workspaceCustomFlatApplication)) throw new Error('Workspace has no custom application; Edit-command guard cannot apply');
const { flatCommandMenuItemMaps } = await workspaceCacheService.getOrRecompute(workspaceId, ['flatCommandMenuItemMaps']);
const editItems = Object.values(flatCommandMenuItemMaps.byUniversalIdentifier).filter((i) => isDefined(i) && i.applicationUniversalIdentifier === workspaceCustomFlatApplication.universalIdentifier && isEditCommand(i));
if (editItems.length === 0) throw new Error('No custom-app Edit commands found to guard'); Try / catch
try {
await command.runOnWorkspace({ workspaceId, options });
} catch (err) {
logger.error(`Edit command guard update failed for workspace ${workspaceId}`, err);
failedWorkspaces.push(workspaceId);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to gate export/import command menu items by permissio
- Failed to update search command menu item labels for workspa
- Failed to add Send Email record-selection commands for works
- Failed to fix merge command menu item expression for workspa
- Failed to update command menu item availability types for wo
AI-assisted analysis of twentyhq/twenty@1f5dd2bbd2 (2026-08-12).
Data as JSON: /api/errors/ae82871117cdb8af.
Report an issue: GitHub.