{"record":{"id":"5f58a3a0c3ed1a7b","repo":"elsa-workflows/elsa-core","slug":"requestbodytoolargeexception-no-message-thrown-when-http","errorCode":null,"errorMessage":"RequestBodyTooLargeException (no message; thrown when HTTP request body read exceeds requestSizeLimit)","messagePattern":"RequestBodyTooLargeException \\(no message; thrown when HTTP request body read exceeds requestSizeLimit\\)","errorType":"error_code","errorClass":"RequestBodyTooLargeException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Http/Activities/HttpEndpoint.cs","lineNumber":613,"sourceCode":"            if (requestedCount == 0)\n                return 0;\n\n            var remainingBytes = requestSizeLimit - _bytesRead;\n            if (remainingBytes >= requestedCount)\n                return requestedCount;\n\n            if (remainingBytes < 0)\n                return 1;\n\n            return (int)remainingBytes + 1;\n        }\n\n        private void CountBytesRead(int bytesRead)\n        {\n            _bytesRead += bytesRead;\n\n            if (_bytesRead > requestSizeLimit)\n                throw new RequestBodyTooLargeException();\n        }\n    }\n\n    private sealed class RequestBodyTooLargeException : Exception;\n}\n","sourceCodeStart":595,"sourceCodeEnd":619,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Http/Activities/HttpEndpoint.cs#L595-L619","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before: activity configured for small payloads\nRequestSizeLimit = 1024 * 100 // 100 KB\n// after\nRequestSizeLimit = 1024 * 1024 * 10 // 10 MB","handlingStrategy":"try-catch","validationCode":"// Client side: check size before uploading\nif (file.Length > maxAllowedBytes)\n    throw new InvalidOperationException($\"Payload {file.Length} bytes exceeds the endpoint limit\");","typeGuard":null,"tryCatchPattern":"// Wrap workflow invocation / activity fault handling\ntry\n{\n    await workflowRunner.RunAsync(workflow, request);\n}\ncatch (Exception ex) when (ex.InnerException is RequestBodyTooLargeException || ex.Message.Contains(\"size\"))\n{\n    httpContext.Response.StatusCode = StatusCodes.Status413PayloadTooLarge;\n}","preventionTips":["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."],"tags":["http","upload","payload-size","workflow"],"backgroundTag":"payload-too-large","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}