elsa-workflows/elsa-core · error · InvalidOperationException
Elsa Platform maximum artifact size must be between 1 byte…
Error message
Elsa Platform maximum artifact size must be between 1 byte and the maximum runtime buffer size.
What it means
MaxArtifactBytes caps the size of command artifacts this runtime will download from the Platform. Validate() requires a value between 1 and Array.MaxLength, protecting the runtime buffer from oversized payloads.
Solutions
- Set MaxArtifactBytes to a sane positive limit, e.g. 10 * 1024 * 1024 (10 MB).
- Fix the bound configuration value so it parses to a positive integer.
- Cap the configured value: Math.Min(configured, Array.MaxLength).
Example fix
// before options.MaxArtifactBytes = 0; // after options.MaxArtifactBytes = 10 * 1024 * 1024;
Defensive patterns
Strategy: validation
Validate before calling
if (options.Enabled && (options.MaxArtifactBytes <= 0 || options.MaxArtifactBytes > Array.MaxLength))
options.MaxArtifactBytes = 10 * 1024 * 1024; Try / catch
try { options.Validate(); }
catch (InvalidOperationException ex) when (ex.Message.Contains("maximum artifact size"))
{
logger.LogError(ex, "MaxArtifactBytes must be between 1 and Array.MaxLength.");
} Prevention
- Use a conservative default (e.g. 10 MB) and document the unit (bytes).
- Validate bound config values parse to positive integers.
- Cap user-configured values with Math.Min against Array.MaxLength.
When it happens
Trigger: Enabled = true plus Validate() with MaxArtifactBytes <= 0 or > Array.MaxLength.
Common situations: Config value bound to 0 or negative from a bad appsettings entry; someone set int.MaxValue * 2 or long.MaxValue; forgetting to set the value when all other options are configured manually.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- Elsa Platform claim lease duration must be between 1 second…
- Elsa Platform poll interval must be positive.
- A configuration key is required.
- Adapter settings migrations must define an adapter type and…
- Configuration connection
AI-assisted analysis of elsa-workflows/elsa-core@fe9217bdfa (2026-09-13).
Data as JSON: /api/errors/5f15cfd63fe79a0f.
Report an issue: GitHub.
Appendix: source
Thrown at src/modules/Elsa.Platform.Integration/Options/ElsaPlatformIntegrationOptions.cs:49
if (!Enabled)
return;
if (PlatformEndpoint is null)
throw new InvalidOperationException("Elsa Platform endpoint is required when Platform integration is enabled.");
if (WorkspaceId == Guid.Empty)
throw new InvalidOperationException("Elsa Platform workspace ID is required when Platform integration is enabled.");
if (EngineId == Guid.Empty)
throw new InvalidOperationException("Elsa Platform engine ID is required when Platform integration is enabled.");
if (string.IsNullOrWhiteSpace(EngineSecret))
throw new InvalidOperationException("Elsa Platform engine secret is required when Platform integration is enabled.");
if (string.IsNullOrWhiteSpace(WorkerId))
throw new InvalidOperationException("Elsa Platform worker ID is required when Platform integration is enabled.");
if (PollInterval <= TimeSpan.Zero)
throw new InvalidOperationException("Elsa Platform poll interval must be positive.");
if (ClaimLeaseDuration < TimeSpan.FromSeconds(1) || ClaimLeaseDuration.TotalSeconds > int.MaxValue)
throw new InvalidOperationException("Elsa Platform claim lease duration must be between 1 second and the maximum supported Platform lease.");
if (MaxArtifactBytes <= 0 || MaxArtifactBytes > Array.MaxLength)
throw new InvalidOperationException("Elsa Platform maximum artifact size must be between 1 byte and the maximum runtime buffer size.");
if (string.IsNullOrWhiteSpace(ShellOverlayPath))
throw new InvalidOperationException("Elsa Platform shell overlay path is required when Platform integration is enabled.");
}
}
View on GitHub (pinned to fe9217bdfa)