twentyhq/twenty · error · Error

Failed to sync "Discard Draft" workflow command menu item av

Error message

Failed to sync "Discard Draft" workflow command menu item availability expression for workspace ${workspaceId}

What it means

Thrown by the 2.28 command that syncs the 'Discard Draft' workflow command menu item's availability expression. It updates the command menu item via validateBuildAndRunLegacyWorkspaceMigration; on status === 'fail' it logs the report and throws. Failure is in the command-menu-item update validation.

Source

Thrown at packages/twenty-server/src/database/commands/upgrade-version-command/2-28/2-28-workspace-command-1785858486000-sync-discard-draft-workflow-availability-expression.command.ts:86

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

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

      throw new Error(
        `Failed to sync "Discard Draft" workflow command menu item availability expression for workspace ${workspaceId}`,
      );
    }

    this.logger.log(
      `Successfully synced "Discard Draft" workflow command menu item availability expression for workspace ${workspaceId}`,
    );
  }
}

View on GitHub (pinned to 1f5dd2bbd2)

Solutions

  1. Read the logged JSON report to see whether the failure is a missing-entity or an expression-validation error.
  2. If the command menu item is missing, ensure the upgrade command that seeds it (earlier in the version chain) ran for the workspace.
  3. If the expression is invalid, correct or clear the stored availability expression for that item, then re-run the 2.28 command.
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the target command menu item exists before running the 2.28 sync:
const item = flatCommandMenuItemMaps.byUniversalIdentifier[DISCARD_DRAFT_UI];
if (!isDefined(item)) { /* run the command that seeds it first */ }

Try / catch

try {
  await command.runOnWorkspace({ workspaceId, options });
} catch (e) {
  logger.error({ workspaceId, err: e.message }, 'Discard Draft availability sync failed');
}

Prevention

When it happens

Trigger: The 'Discard Draft' command menu item universalIdentifier does not exist in the workspace (so the update targets nothing); the availability expression string fails the expression validator (syntax/unknown reference); the twentyStandardFlatApplication linkage is broken for the workspace.

Common situations: Workspace on a version that never had the Discard Draft command menu item seeded; the expression references a field/object that was since renamed; cross-version upgrade where an intermediate command that creates the item was skipped.

Related errors


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