-
Notifications
You must be signed in to change notification settings - Fork 463
Add implementation to treat message size limit exceed as an error #2434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add implementation to treat message size limit exceed as an error #2434
Conversation
WalkthroughAdds message-size-limit signalling and enforcement across the passthru transport: two new constants; TargetHandler detects oversized responses via Content-Length and marks source contexts; SourceHandler and PassThroughHttpSender inspect those marks to modify status and suppress bodies; SourceResponse gains a status-line setter; flags are cleared after use. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Backend
participant TargetHandler
participant SourceConn as "Source Connection\nContext"
participant SourceHandler
participant SourceResponse
participant PassThroughHttpSender
participant Client
Backend->>TargetHandler: responseReceived (with Content-Length)
activate TargetHandler
alt Content-Length > configured limit && validation enabled
TargetHandler->>SourceConn: set MESSAGE_SIZE_LIMIT_EXCEEDED
opt drop configured
TargetHandler->>SourceConn: set DROP_MESSAGE_DUE_TO_SIZE_LIMIT_EXCEEDED
end
end
deactivate TargetHandler
SourceHandler->>SourceHandler: responseReady()
activate SourceHandler
alt SOURCE context has MESSAGE_SIZE_LIMIT_EXCEEDED
SourceHandler->>SourceResponse: setStatusLine("Response Entity Too Large")
SourceHandler->>SourceHandler: set status 502
SourceHandler->>SourceConn: remove MESSAGE_SIZE_LIMIT_EXCEEDED
end
deactivate SourceHandler
SourceHandler->>PassThroughHttpSender: submitResponse(SourceResponse)
activate PassThroughHttpSender
alt SOURCE context has DROP_MESSAGE_DUE_TO_SIZE_LIMIT_EXCEEDED
PassThroughHttpSender->>PassThroughHttpSender: set NO_ENTITY_BODY = true
PassThroughHttpSender->>SourceConn: remove DROP_MESSAGE_DUE_TO_SIZE_LIMIT_EXCEEDED
end
PassThroughHttpSender->>Client: send response (status, possibly no body)
deactivate PassThroughHttpSender
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🔇 Additional comments (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/PassThroughConstants.java(1 hunks)modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/PassThroughHttpSender.java(1 hunks)modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/SourceHandler.java(1 hunks)modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/SourceResponse.java(1 hunks)modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/TargetHandler.java(4 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/SourceHandler.java (1)
modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/PassThroughConstants.java (1)
PassThroughConstants(19-282)
modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/PassThroughHttpSender.java (1)
modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/PassThroughConstants.java (1)
PassThroughConstants(19-282)
modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/TargetHandler.java (2)
modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/PassThroughConstants.java (1)
PassThroughConstants(19-282)modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/TargetContext.java (1)
TargetContext(34-258)
🔇 Additional comments (2)
modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/PassThroughConstants.java (1)
279-281: New size-limit context flags look consistent
MESSAGE_SIZE_LIMIT_EXCEEDEDandDROP_MESSAGE_DUE_TO_SIZE_LIMIT_EXCEEDEDare named clearly and align with their usage in SourceHandler/TargetHandler/PassThroughHttpSender. No issues here.modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/SourceResponse.java (1)
347-353:setStatusLinesetter is fineThe new
setStatusLine(String)cleanly exposes existingstatusLineand works with the logic instart(). No functional concerns.
Purpose
With this change, when the following is turned on:
and when the message payload exceeds the specified size, the response will have a HTTP Status code of
502, with the status lineResponse Entity Too Large.Further the
drop.message.when.size.limit.exceededhas been introduced as follows. If this property is set to true, the payload in the response body will be dropped (no entity body).Examples with
"message.size.validation.enabled" = "true"Dropped Payload (
"drop.message.when.size.limit.exceeded" = "true")Partial Payload Delivered (
"drop.message.when.size.limit.exceeded" = "false")Summary by CodeRabbit
New Features
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.