twentyhq/twenty · error · Error

Failed to update command menu item availability types for wo

Error message

Failed to update command menu item availability types for workspace ${workspaceId}

What it means

Thrown by the 1.23 workspace upgrade command when validateBuildAndRunLegacyWorkspaceMigration returns 'fail' while updating availability types on global/object-context command menu items. The full validateAndBuildResult JSON is logged before the throw.

Source

Thrown at packages/twenty-server/src/database/commands/upgrade-version-command/1-23/1-23-workspace-command-1780000005000-update-global-object-context-command-menu-items.command.ts:133

          allFlatEntityOperationByMetadataName: {
            commandMenuItem: {
              flatEntityToCreate: [],
              flatEntityToDelete: [],
              flatEntityToUpdate: itemsToUpdate,
            },
          },
          workspaceId,
          applicationUniversalIdentifier:
            twentyStandardFlatApplication.universalIdentifier,
        },
      );

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

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

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

View on GitHub (pinned to 1f5dd2bbd2)

Solutions

  1. Inspect the logged validateAndBuildResult JSON for the rejected availability type or missing item.
  2. Recompute the workspace cache and re-run.
  3. Run --dryRun to confirm itemsToUpdate targets the expected global/object-context items.
  4. Isolate and reconcile the failing workspace's command menu items.
Defensive patterns

Strategy: validation

Validate before calling

// Dry-run to preview availability-type changes, and confirm target items exist in cache:
await workspaceCacheService.invalidate(workspaceId);
const { flatCommandMenuItemMaps } = await workspaceCacheService.getOrRecompute(workspaceId, ['flatCommandMenuItemMaps']);
const targetsExist = TARGET_ITEM_IDS.every((id) => isDefined(flatCommandMenuItemMaps.byUniversalIdentifier[id]));
if (!targetsExist) throw new Error('Target command menu items missing; cannot update availability types');

Try / catch

try {
  await command.runOnWorkspace({ workspaceId, options });
} catch (err) {
  logger.error(`Availability type update failed for workspace ${workspaceId}`, err);
  failedWorkspaces.push(workspaceId);
}

Prevention

When it happens

Trigger: Running the 1.23 availability-type update on a workspace whose command menu items are absent from cache, or whose new availabilityType values the builder rejects (invalid enum, incompatible with the item's context).

Common situations: Stale cache returning undefined items; availability type value not in the allowed set for that build; partial prior upgrade left items mid-change.

Related errors


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