elsa-workflows/elsa-core · error · RequestBodyTooLargeException
RequestBodyTooLargeException (no message; thrown when HTTP…
Error message
RequestBodyTooLargeException (no message; thrown when HTTP request body read exceeds requestSizeLimit)
What it means
HttpEndpoint wraps the incoming HTTP request body in a RequestSizeLimitStream that counts bytes as they are read and throws RequestBodyTooLargeException the moment the accumulated total exceeds requestSizeLimit. This enforces the activity's RequestSizeLimit setting so workflows do not buffer arbitrarily large uploads. It is a private nested exception with no message, surfaced to the caller as a request-size violation.
Solutions
- Increase the RequestSizeLimit property on the HttpEndpoint activity to accommodate expected payload sizes.
- Have the client reduce/compress the request body, or stream the upload to storage in chunks instead of through the workflow body.
- Return a clear 413 response to clients by handling the size exception in the workflow's fault path and informing senders of the allowed size.
Example fix
// before: activity configured for small payloads RequestSizeLimit = 1024 * 100 // 100 KB // after RequestSizeLimit = 1024 * 1024 * 10 // 10 MB
Defensive patterns
Strategy: try-catch
Validate before calling
// Client side: check size before uploading
if (file.Length > maxAllowedBytes)
throw new InvalidOperationException($"Payload {file.Length} bytes exceeds the endpoint limit"); Try / catch
// Wrap workflow invocation / activity fault handling
try
{
await workflowRunner.RunAsync(workflow, request);
}
catch (Exception ex) when (ex.InnerException is RequestBodyTooLargeException || ex.Message.Contains("size"))
{
httpContext.Response.StatusCode = StatusCodes.Status413PayloadTooLarge;
} Prevention
- Publish the allowed payload size in your API documentation.
- Set RequestSizeLimit on the activity consistent with Kestrel's MaxRequestBodySize.
- Have clients compress or chunk large uploads.
When it happens
Trigger: A client POSTs (or PUTs) a body larger than the HttpEndpoint activity's configured requestSizeLimit, and the workflow reads the request body through the limited stream (e.g., reading form fields or raw body content).
Common situations: Users uploading files larger than the configured limit, clients sending large JSON payloads to a workflow endpoint, default Kestrel/body limits interacting with the activity limit, or a workflow configured with a small limit during testing being hit with production-sized uploads.
Understand the failure class
Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.
Related errors
- RequestBodyTooLargeException
- ResponseTooLarge
- NoHttpContext
- NoHttpContext
- Content of type is not supported.
AI-assisted analysis of elsa-workflows/elsa-core@fe9217bdfa (2026-09-13).
Data as JSON: /api/errors/5f58a3a0c3ed1a7b.
Report an issue: GitHub.
Appendix: source
Thrown at src/modules/Elsa.Http/Activities/HttpEndpoint.cs:613
if (requestedCount == 0)
return 0;
var remainingBytes = requestSizeLimit - _bytesRead;
if (remainingBytes >= requestedCount)
return requestedCount;
if (remainingBytes < 0)
return 1;
return (int)remainingBytes + 1;
}
private void CountBytesRead(int bytesRead)
{
_bytesRead += bytesRead;
if (_bytesRead > requestSizeLimit)
throw new RequestBodyTooLargeException();
}
}
private sealed class RequestBodyTooLargeException : Exception;
}
View on GitHub (pinned to fe9217bdfa)