fix: enforce request body size limit during buffering in AiProxyPlugin - #6897
Open
wy471x wants to merge 2 commits into
Open
fix: enforce request body size limit during buffering in AiProxyPlugin#6897wy471x wants to merge 2 commits into
wy471x wants to merge 2 commits into
Conversation
Use DataBufferUtils.join with maxSize to prevent OOM from large request bodies. Previously the full body was buffered into memory before the size check ran, allowing a multi-GB payload to exhaust heap. Now DataBufferLimitException is raised during buffering and returned as 413. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use DataBufferUtils.join with maxSize to prevent OOM from large request bodies. Previously the full body was buffered into memory before the size check ran, allowing a multi-GB payload to exhaust heap. Now DataBufferLimitException is raised during buffering and returned as 413.
Make sure that:
./mvnw clean install -Dmaven.javadoc.skip=true.Summary
Spring's DataBufferUtils enforce the 5 MB limit during buffering — a DataBufferLimitException is thrown immediately when the limit is exceeded, rather than buffering the entire
multi-GB body into heap first. Added .onErrorResume(DataBufferLimitException.class, ...) to catch that exception and return HTTP 413. Removed the now-redundant post-buffer size
check.
PAYLOAD_TOO_LARGE.
close #6837