elsa-workflows/elsa-core · error · InvalidOperationException
Elsa Platform claim lease duration must be between 1 second…
Error message
Elsa Platform claim lease duration must be between 1 second and the maximum supported Platform lease.
What it means
ClaimLeaseDuration is the lease duration requested when this worker claims a Platform command. Validate() requires it to be at least 1 second and at most int.MaxValue seconds, matching the maximum lease the Platform supports.
Solutions
- Set ClaimLeaseDuration to a value between 1 second and int.MaxValue seconds, e.g. TimeSpan.FromMinutes(5).
- Clamp the value in code: Math.Max(TimeSpan.FromSeconds(1), configuredLease).
- Check that configuration parsing did not produce a sub-second value from a string like '0.5'.
Example fix
// before options.ClaimLeaseDuration = TimeSpan.FromMilliseconds(500); // after options.ClaimLeaseDuration = TimeSpan.FromMinutes(5);
Defensive patterns
Strategy: validation
Validate before calling
var min = TimeSpan.FromSeconds(1);
var max = TimeSpan.FromSeconds(int.MaxValue);
if (options.Enabled && (options.ClaimLeaseDuration < min || options.ClaimLeaseDuration > max))
options.ClaimLeaseDuration = TimeSpan.FromMinutes(5); Try / catch
try { options.Validate(); }
catch (InvalidOperationException ex) when (ex.Message.Contains("claim lease"))
{
logger.LogError(ex, "ClaimLeaseDuration out of range [1s, int.MaxValue s].");
} Prevention
- Clamp configured lease durations to the supported range before validation.
- Avoid TimeSpan.MaxValue-style sentinel values; use finite durations.
- Match lease duration to expected command processing time plus margin.
When it happens
Trigger: Enabled = true plus Validate() with ClaimLeaseDuration < TimeSpan.FromSeconds(1) or ClaimLeaseDuration.TotalSeconds > int.MaxValue.
Common situations: Setting a sub-second lease (e.g. TimeSpan.FromMilliseconds(500)) for fast tests; setting TimeSpan.MaxValue or an unbounded duration; unit tests constructing options with default(TimeSpan).
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 maximum artifact size must be between 1 byte…
- 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/e09f0896a9dabe44.
Report an issue: GitHub.
Appendix: source
Thrown at src/modules/Elsa.Platform.Integration/Options/ElsaPlatformIntegrationOptions.cs:47
public void Validate()
{
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)