OrchardCMS/OrchardCore · error · ArgumentOutOfRangeException

Invalid bulk action.

Error message

Invalid bulk action.

What it means

DeploymentPlanController.Index POST validates the submitted bulk-action value against a known set (e.g. delete) and throws ArgumentOutOfRangeException for anything unrecognized. The library only supports the bulk actions it renders in the UI, so any other value is rejected as invalid.

Solutions

  1. Post only supported bulk action values exactly as rendered by the admin UI form.
  2. Clear browser cache / refresh the admin page so a stale form posts current values.
  3. If adding a custom bulk action, extend the controller switch statement to handle the new value.
  4. Wrap the post in error handling and validate the BulkAction value client-side before submission.

Example fix

// before
<form method="post"><input name="BulkAction" value="purge-all" />...</form>
// after
<form method="post"><input name="BulkAction" value="Delete" />...</form>
Defensive patterns

Strategy: try-catch

Validate before calling

var allowed = new[] { "Delete" };
if (!allowed.Contains(bulkAction, StringComparer.OrdinalIgnoreCase))
    throw new ArgumentException($"Unsupported bulk action '{bulkAction}'.");

Try / catch

try { await client.PostAsync("/Admin/DeploymentPlan/Index", form); } catch (ArgumentOutOfRangeException ex) { logger.LogError(ex, "Invalid bulk action posted"); }

Prevention

When it happens

Trigger: Posting to the Deployment Plan Index action with form field BulkAction set to a value not handled by the switch statement (e.g. tampered form, stale client, custom script or integration sending an unsupported action).

Common situations: Custom admin scripts or automated tooling posting to the deployment plans endpoint with a hardcoded bulk action string that does not match the shipped options; a UI/plugin change that adds an option without adding the server-side switch case.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13). Data as JSON: /api/errors/eda8e7b479ff6b6e. Report an issue: GitHub.

Appendix: source

Thrown at src/OrchardCore.Modules/OrchardCore.Deployment/Controllers/DeploymentPlanController.cs:149

            return Forbid();
        }

        if (itemIds?.Any() == true)
        {
            var checkedItems = await _session.Query<DeploymentPlan, DeploymentPlanIndex>().Where(x => x.DocumentId.IsIn(itemIds)).ListAsync();
            switch (options.BulkAction)
            {
                case ContentsBulkAction.None:
                    break;
                case ContentsBulkAction.Delete:
                    foreach (var item in checkedItems)
                    {
                        _session.Delete(item);
                    }
                    await _notifier.SuccessAsync(H["Deployment plans successfully deleted."]);
                    break;
                default:
                    throw new ArgumentOutOfRangeException(options.BulkAction.ToString(), "Invalid bulk action.");
            }
        }

        return RedirectToAction(nameof(Index));
    }

    public async Task<IActionResult> Display(long id)
    {
        if (!await _authorizationService.AuthorizeAsync(User, DeploymentPermissions.ManageDeploymentPlan))
        {
            return Forbid();
        }

        var deploymentPlan = await _session.GetAsync<DeploymentPlan>(id);

        if (deploymentPlan == null)
        {
            return NotFound();

View on GitHub (pinned to 4306c0717f)