twentyhq/twenty · error · Error

Failed to sync command menu item availability expressions fo

Error message

Failed to sync command menu item availability expressions for workspace ${workspaceId}

What it means

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.

Source

Thrown at packages/twenty-server/src/database/commands/upgrade-version-command/2-13/2-13-workspace-command-1781277470000-sync-create-record-command-availability-expression.command.ts:127

              flatEntityToDelete: [],
              flatEntityToUpdate: itemsToUpdate,
            },
          },
          workspaceId,
          // Standard command menu items are system-owned; without a system
          // build the validator rejects direct updates.
          isSystemBuild: true,
          applicationUniversalIdentifier:
            twentyStandardFlatApplication.universalIdentifier,
        },
      );

    if (validateAndBuildResult.status === 'fail') {
      this.logger.error(
        `Failed to sync command menu item availability expressions:\n${JSON.stringify(validateAndBuildResult, null, 2)}`,
      );

      throw new Error(
        `Failed to sync command menu item availability expressions for workspace ${workspaceId}`,
      );
    }

    this.logger.log(
      `Successfully synced ${itemsToUpdate.length} command menu item availability expression(s) for workspace ${workspaceId}`,
    );
  }
}

View on GitHub (pinned to 1f5dd2bbd2)

Solutions

  1. Read the logged validateAndBuildResult JSON for the exact expression or lookup error.
  2. Recompute the workspace cache and re-run.
  3. Run --dryRun to confirm itemsToUpdate targets the create-record items.
  4. Verify the expression's referenced entities exist in the failing workspace.
Defensive patterns

Strategy: validation

Validate before calling

// Dry-run to preview availability-expression changes, and confirm create-record items exist in cache:
await workspaceCacheService.invalidate(workspaceId);
const { flatCommandMenuItemMaps } = await workspaceCacheService.getOrRecompute(workspaceId, ['flatCommandMenuItemMaps']);
const createItems = Object.values(flatCommandMenuItemMaps.byUniversalIdentifier).filter((i) => isDefined(i) && isCreateRecordCommand(i));
if (createItems.length === 0) throw new Error('No create-record command menu items found to sync');

Try / catch

try {
  await command.runOnWorkspace({ workspaceId, options });
} catch (err) {
  logger.error(`Create-record availability sync failed for workspace ${workspaceId}`, err);
  failedWorkspaces.push(workspaceId);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of twentyhq/twenty@1f5dd2bbd2 (2026-08-12). Data as JSON: /api/errors/2e099c23d02061c4. Report an issue: GitHub.