Skip to content

http: buffer body data per filter - #48660

Merged
wbpcode merged 4 commits into
envoyproxy:mainfrom
wbpcode:dev-per-filter-buffering
Nov 23, 2026
Merged

wbpcode merged 4 commits into
envoyproxy:mainfrom
wbpcode:dev-per-filter-buffering

Conversation

@wbpcode

@wbpcode wbpcode commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Commit Message: http: buffer body data per filter with an aggregate stream buffer limit
Additional Description:
The filter manager buffers all stopped body data of a stream in one buffer shared per direction. Data stopped at different filters gets mixed, and a filter that resumes iteration replays whatever is in the shared buffer, including bytes still held by an earlier filter. Those bytes skip the filters in between, or are sent twice (for example, the router resends the body it kept for retries).

With envoy.reloadable_features.filter_manager_per_filter_buffer enabled, each filter has its own buffer:

  • bufferedData() returns the filter's own buffer, so a filter only ever replays the data stopped at it. Filters never switch between buffers, which removes the class of bugs where data moves to the wrong buffer when the latest data filter changes.
  • decodingBuffer()/encodingBuffer(), add{Decoded,Encoded}Data() and modify{Decoding,Encoding}Buffer() operate on the calling filter's own buffer. decodingBuffer() no longer returns body data buffered by other filters (the contract change is documented in envoy/http/filter.h and the dynamic modules ABI header).
  • A body added by several filters while the headers of a header-only stream pass through the chain is moved into the first adder's buffer and sent once, as with the shared buffer.
  • The stream buffer limit applies to the total held by all buffers in each direction. A per-direction PerFilterBufferTracker fires the watermark / too-large handling with the same hysteresis as WatermarkBuffer; moves between two filters' buffers are one net change and do not toggle flow control. A 413/500 caused by exceeding the limit is owned by the filter whose processing exceeded it.
  • takeBufferedRequestData() also collects the filters' own buffers, in stream order, for stream recreation.
  • The router drops the body it kept for retries/redirects once it gives up on them because the body exceeds the retry buffer limit. Otherwise the kept body would hold the total above the low watermark after an earlier filter applied backpressure, and downstream reads would never resume.
  • Adds ENVOY_RUNTIME_FEATURE_ENABLED, which resolves the runtime flag once per call site, used for the per-stream flag reads.

The guard is disabled by default because out-of-tree extensions may read the body buffered by other filters through decodingBuffer()/encodingBuffer(). With the guard disabled the behavior is unchanged. The same guard also enables the per-filter observed end stream tracking from #49286.

Also fixes #46095.
Risk Level: Medium (no change unless the runtime guard is enabled)
Testing: unit tests for both guard values (filter manager, HCM, router, runtime), integration tests (filter, protocol, multiplexed, buffer accounting, redirect, shadow, ext_proc); benchmark added.
Docs Changes: API comments in envoy/http/filter.h and the dynamic modules ABI.
Release Notes: added (behavior change, bug fix).
Platform Specific Features: N/A
Runtime guard: envoy.reloadable_features.filter_manager_per_filter_buffer (default false)

@repokitteh-read-only

Copy link
Copy Markdown

CC @envoyproxy/runtime-guard-changes: FYI only for changes made to (source/common/runtime/runtime_features.cc).

🐱

Caused by: #48660 was opened by wbpcode.

see: more, trace.

@wbpcode
wbpcode force-pushed the dev-per-filter-buffering branch from 04b5191 to f2f5ea7 Compare October 24, 2026 14:38
@wbpcode wbpcode changed the title http: buffer body data per filter with an aggregate stream buffer limit http: buffer body data per filter Oct 25, 2026
@yanavlasov

Copy link
Copy Markdown
Contributor

@paul-r-gall ^^^

@yanjunxiang-google

Copy link
Copy Markdown
Contributor

/assign @yanjunxiang-google

@wbpcode

wbpcode commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

/coverage

@repokitteh-read-only

Copy link
Copy Markdown

Coverage for this Pull Request will be rendered here:

https://storage.googleapis.com/envoy-cncf-pr/48660/coverage/index.html

For comparison, current coverage on main branch is here:

https://storage.googleapis.com/envoy-cncf-postsubmit/main/coverage/index.html

The coverage results are (re-)rendered each time the CI Envoy/Checks (coverage) job completes.

🐱

Caused by: a #48660 (comment) was created by @wbpcode.

see: more, trace.

Comment thread source/common/http/filter_manager.cc Resolved
Comment thread source/common/http/filter_manager.cc Resolved
Comment thread source/common/http/filter_manager.cc Resolved
Comment thread test/common/http/filter_manager_test.cc Resolved
Comment thread source/common/http/filter_manager.h Resolved
@paul-r-gall

Copy link
Copy Markdown
Contributor

oh one more thing -- Can you please re-run the filtermanager benchmarks to make sure this is not a perf hit? Thanks.

@wbpcode

This comment was marked as outdated.

@wbpcode

wbpcode commented Oct 31, 2026 •

Copy link
Copy Markdown
Member Author

I refactored the way to fetch runtime. Now it's much better. At least we could ensure there is no obvious perf degradation.

Benchmark main (ns) branch (ns) Δ
CreateDestroy 363 382 +18 (+5.1%)
HeaderOnly/3 874 922 +48 (+5.5%)
HeaderOnly/10 1371 1435 +64 (+4.7%)
StreamingBody/3 2192 2240 +48 (+2.2%)
StreamingBody/10 3076 3178 +102 (+3.3%)
BufferedBody/3 2918 2876 -42 (-1.4%)
BufferedBody/10 3659 3670 +11 (+0.3%)
BufferedBodyTwoFilters/3 3316 3512 +196 (+5.9%)
BufferedBodyTwoFilters/10 3932 4168 +236 (+6.0%)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suppose you have A->B. A stops on "raw-bytes", then calls continueDecoding() later on. A is now IterationState::Continue, and B receives *A.buffered_data_ and suppose it returns StopIterationNoBuffer without draining data (e.g. streamed ext_proc, a compressor, or router when not buffering). "raw-bytes" stays inside A.buffered_data_ (and stays charged to request_buffer_tracker_.total_) while A is Continue. If A stops again on a later chunk "more-bytes", "more-bytes" is appended behind "raw-bytes" in A.buffered_data_, so B gets "raw-bytes" a second time (and takeBufferedRequestData() walks in reverse and puts B's later data before A's stale "raw-bytes").

doData() needs to move buffered_data_ out into a local buffer before calling decodeData / encodeData OR needs to drain/delete buffered_data_ once the stack unwinds. Basically, after A.continueDecoding() is triggered, at the end of that stack, A.buffered_data_ should be either nullptr or drained.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. This is an existing problem; it's fixed for per-filter buffering by draining the input whenever a filter returns StopIterationNoBuffer, the same as the codecs do for the data they dispatch. Whatever a later filter leaves behind is dropped, so it's never sent again. A filter replayed its own buffer after StopAll keeps it, which the router relies on to keep the body for retries.

Comment thread source/common/http/filter_manager.cc Resolved
Comment thread source/common/http/filter_manager.cc Resolved
Comment thread source/common/http/filter_manager.cc Resolved
Comment thread source/common/http/filter_manager.cc Resolved
Comment thread source/common/http/filter_manager.cc Resolved
Comment thread source/common/http/filter_manager.cc Resolved
@wbpcode

wbpcode commented Nov 8, 2026

Copy link
Copy Markdown
Member Author

Addressed the latest round. Besides the inline fixes, trailers handling with per-filter buffering is reworked around one "held at" position per direction, which fixes several pre-existing ordering/duplication cases; the existing shared-buffer path is unchanged. filter_manager and conn_manager tests pass in debug and release.

@wbpcode

wbpcode commented Nov 8, 2026

Copy link
Copy Markdown
Member Author

Hello, @paul-r-gall , thanks for your great review! That makes huge sense! Most of these problems are inherited from the previous implementation. Except your commends, I also found some more edge cases. In the new code path, I fixed all problems we found until now! Although I cannot ensure it has resolved all problems, it's much better than our previous version (shared buffer one) anyway.

@wbpcode

wbpcode commented Nov 9, 2026

Copy link
Copy Markdown
Member Author

/retest

@paul-r-gall

Copy link
Copy Markdown
Contributor

Overall:

  1. this LGTM
  2. this also scares the bejeezus out of me cause filter manager state machine is a nightmare.

paul-r-gall
paul-r-gall previously approved these changes Nov 11, 2026
@wbpcode

wbpcode commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

Overall:

  1. this LGTM
  2. this also scares the bejeezus out of me cause filter manager state machine is a nightmare.

🤣

@agrawroh agrawroh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Suggested Fixes. Per-filter positions are the right model, and letting a filter with no buffer of its own see and take over a replayed buffer would fix the first blocker and two suggestions below.

  • ⚠️ By default decodingBuffer() and encodingBuffer() return only this filter's bytes, unlike their documented contract.
  • ⚠️ Once the router gives up retry or redirect buffering, its kept body still counts toward the limit.
  • ⚠️ If an earlier filter added trailers and this frame pushes the stopped filter past the limit, the 500 goes straight to the codec and, on HTTP/1, the filters are destroyed before this forward runs.
  • ❓ With the guard on, an injection no longer rewrites the stream's end-of-stream flag, so on a TCP tunnel with independent half-close a finished response stops proxying the rest of an injected body, as the close check's comment describes.
  • 💡 An iterating filter that adds to a replayed frame and continues now gets those bytes forwarded only if it moved a non-empty frame into its buffer and filter_manager_forward_added_data_on_continue is on.
  • 💡 A filter that buffers an earlier filter's replayed frame now allocates a second 1.2 KiB buffer and moves every slice, and the drained source lives until the stream ends.
  • 💡 Every filter manager now carries 272 more bytes, guards on or off, and a proxied request builds at least two.
  • 💡 Operators and extension authors will see more than this says.
  • 💡 These handlers repeat requestDataTooLarge(), responseDataTooLarge() and the drained callbacks, and the two 500 paths already differ on the owner.
  • 💡 This public overload calls .value() on whatever flag it gets, while only the registry checks the type.
  • 💡 inject_data_with_state_update_ matters only with the observed-end-stream guard off, so could we skip its read when that guard is on?
  • 💡 This block describes both guards, so filter_manager_per_filter_observed_end_stream has no comment of its own.
  • 💡 These guard-off tests compare concatenated bytes, so they pass with the observed-end-stream guard on or off, and no guard-off test sends request trailers.
  • 💡 These end-to-end tests run only over HTTP/2, so HTTP/1 chunked trailers and HTTP/3 are not exercised on the new path.
  • 💡 The description still says this is stacked on #48556, names observed_trailers_ and says takeBufferedRequestData() replaces bufferedRequestData(). Since the description becomes the commit message, could we update it to the final design and both guards?
  • 💡 The posted benchmark table predates the last two filter-manager commits and has no guards-off arm. Could we rerun it at the head with repetitions, once with both guards false through --runtime_feature?

Comment thread source/common/http/filter_manager.cc Outdated
}
}

Buffer::InstancePtr& ActiveStreamFilterBase::bufferedData() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ By default decodingBuffer() and encodingBuffer() return only this filter's bytes, unlike their documented contract. After an earlier filter buffers and resumes, grpc_web drops its grpc-message cap and a module rewriting only its buffered view forwards the original. Could a filter without a buffer see and take over the replayed one, or could the contract and both consumers change here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather change the contract rather than to let a filter adopt an earlier filter's replayed buffer: that way will brings back shared ownership (aliasing with the in-flight data, accounting charged to the wrong filter, ambiguous trailer holder), which is exactly what this PR removes.

The state a filter now sees after an earlier filter replays (no own buffer, whole body in data) is not new: it is what every filter already sees on main when the body arrives as a single big end_stream chunk.

grpc_web's single-chunk path is already uncapped on main (local replies or a large single upstream frame), so I'll cap it unconditionally (you comment actually find a bug of the grpc_web, I will fix it).

Dynamic modules that write Buffered*Body without checking that it exists already drop or strand data on main in the single-chunk case. I'll document in the ABI that at end of stream the body is buffered + received. I'll update the decodingBuffer()/encodingBuffer() docs to "this filter's own buffered bytes; a replayed body arrives as data", and add a changelog note.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also #49226 which have hardened the grpc_web.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shared buffer now stays with the latest data filter, so the module, grpc_web and bridge cases I probed behave as they do on main in those chains.

}
return;
}
if (above_high_watermark_called_ && (high_watermark_ == 0 || total_ <= low_watermark_)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Once the router gives up retry or redirect buffering, its kept body still counts toward the limit. If a StopIterationAndWatermark pause pushed the total over and that body stays above half, reads stay disabled until the upstream answers or a timeout fires, where the shared buffer duplicated those bytes. Could the router drop its kept bytes when giving up?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a regression. On main the router also never drains its kept body when it gives up on retry/redirect (request_buffer_overflowed_ only stops further addDecodedData()), so those bytes stay in the shared buffer above the low watermark in exactly the same way. The bytes aren't duplicated either: on main the replayed buffer is the shared buffer, so the router's addDecodedData() is a no-op. Here they move from the paused filter's buffer into the router's, and the tracker counts them once in both cases. Draining the kept body on give-up is a good idea, but it changes the router independently of this PR and improves main equally, so I'd do it as a small follow-up rather than add it here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed it can follow in #49220, as long as its drain runs only on streams that latched per-filter buffering, which the router can't see yet.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The router now drops its kept body when it gives up on overflow, and the new router comments ask for the other give-up paths and the stream's latched mode.

Comment thread source/common/http/filter_manager.cc Outdated
data_nonempty_before_callback)) {
if (per_filter_buffer_) {
// Trailers added by an earlier filter in this pass follow the data up to here.
forwardHeldResponseTrailers();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ If an earlier filter added trailers and this frame pushes the stopped filter past the limit, the 500 goes straight to the codec and, on HTTP/1, the filters are destroyed before this forward runs. A local reply from that late encodeTrailers(), like wasm's fail-closed one, then resets a destroyed stream. Could this guard also return once the chain is complete?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, another edge case! Thanks for the findings. Will address this issue.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by #49241, since the forward now returns once the chain is complete or the filters are gone.

Comment thread source/common/http/filter_manager.cc Outdated
observed_end_stream_ = end_stream;
// With per-filter observed end stream, the stream-level flag is left untouched: it records
// what the downstream client actually sent and drives lifecycle decisions.
if (!parent_.per_filter_observed_end_stream_ && parent_.inject_data_with_state_update_) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ With the guard on, an injection no longer rewrites the stream's end-of-stream flag, so on a TCP tunnel with independent half-close a finished response stops proxying the rest of an injected body, as the close check's comment describes. Does ext_proc rely on the old behavior? Either way, could a test pin both inject values?

@wbpcode wbpcode Nov 13, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our new flag will cover the previous flag. The previous flag actually cannot fix the ext_proc problem completely. See the #48556 description. It explains the ext_proc's problem clearly. We should have added tests to cover this? (2 ext_proc filter tests and 3 ext_proc filter tests)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the new half-close test pins that the rest of an injected body is dropped once the response ends, which matches what the close check describes.

Comment thread source/common/http/filter_manager.cc Outdated
// continue iteration in the future, we use the buffered data. A future filter can stop and
// buffer again. In this case, since we are already operating on buffered data, we don't
// rebuffer, because we assume the filter has modified the buffer as it wishes in place.
// With per-filter buffer, the bytes move forward into this filter's own buffer instead, so

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 An iterating filter that adds to a replayed frame and continues now gets those bytes forwarded only if it moved a non-empty frame into its buffer and filter_manager_forward_added_data_on_continue is on. Behind a buffering filter, an empty chunked body through grpc_http1_bridge's protobuf upgrade loses its prepended frame header. The replayed-buffer takeover fixes both.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some way, this actually is another bug of the filter itself. A strictly correct filter should only use the add*Data/decodingBuffer/encodingBufufer/modifyDecodingBuffer/modifyEncodingBuffer when the filter actually buffered the data, or it should operate the provided data directly.

But I guess this does expose a problem. We cannot ensure the out-of-tree be correct strictly. And this new feature may break out-of-tree extensions silently.

@wbpcode wbpcode Nov 13, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix the filter self, and try make the replayed buffer be accessible by the decodingBuffer

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #49226 also.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by #49226 together with the shared buffer staying with the latest filter, and the empty-body bridge case keeps its header now.

bool runtimeFeatureEnabled(absl::string_view feature);
// Same as above, for a flag already resolved via RuntimeFeaturesDefaults::get().getFlag(feature).
// A null flag is reported as an unknown feature.
bool runtimeFeatureEnabled(absl::CommandLineFlag* flag, absl::string_view feature);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 This public overload calls .value() on whatever flag it gets, while only the registry checks the type. Could it move to a detail namespace, or check the type like the unknown-name case?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still public at this head, and it doesn't block.

proxy_100_continue_(proxy_100_continue),
per_filter_observed_end_stream_(ENVOY_RUNTIME_FEATURE_ENABLED(
"envoy.reloadable_features.filter_manager_per_filter_observed_end_stream")),
inject_data_with_state_update_(ENVOY_RUNTIME_FEATURE_ENABLED(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 inject_data_with_state_update_ matters only with the observed-end-stream guard off, so could we skip its read when that guard is on?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This read is in the copy #49286 carries too, so it can move there.

// forward that buffered data down the chain instead of the now-empty frame, so the frame is not
// lost. See https://github.com/envoyproxy/envoy/issues/46841
RUNTIME_GUARD(envoy_reloadable_features_filter_manager_forward_added_data_on_continue);
// When resuming filter chain iteration, compute end_stream from whether the end of the stream has

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 This block describes both guards, so filter_manager_per_filter_observed_end_stream has no comment of its own. Could we split it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still one comment for both guards, and it doesn't block.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's one guard now, and its comment covers both behaviors.

Comment thread test/common/http/filter_manager_test.cc Outdated
filters_[1]->decoder_callbacks_->continueDecoding();
filters_[0]->decoder_callbacks_->continueDecoding();
// "bbb" bypasses filter 1.
EXPECT_EQ("aaa", concat(records_[1].decoded_data));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 These guard-off tests compare concatenated bytes, so they pass with the observed-end-stream guard on or off, and no guard-off test sends request trailers. Could they assert each chunk's end_stream, and add request-trailers and inject cases?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests still compare concatenated bytes, so a per-chunk end-of-stream check with a last filter that keeps the body, and a guard-off inject case, would still help.

"@type": type.googleapis.com/test.integration.filters.UppercaseBufferFilterConfig
)EOF";

TEST_P(FilterIntegrationTest, PerFilterBufferRequestBodyBufferedAtTwoFilters) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 These end-to-end tests run only over HTTP/2, so HTTP/1 chunked trailers and HTTP/3 are not exercised on the new path. Could they run under MultiProtocolFilterIntegrationTest?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These still cover only one protocol, and it doesn't block.

phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
)

`wasm_filter_integration_test` sent the request body straight after the
headers. Until the upstream connection is ready the upstream codec
filter holds the headers, and when it resumes it is given whatever body
an earlier filter has buffered so far (the buffer is shared by the
filter chain, see envoyproxy#48660). When that happened between two chunks of the
body, the upstream wasm filter that was buffering it no longer owned the
buffered data and failed
`ASSERT(parent_.state_.latest_data_decoding_filter_ == this)` on the
next chunk.

Send the body once the request headers have reached the upstream, so
that the codec filter is not waiting on the connection while the body
arrives.

Backport note: picked from the pull request ahead of its merge to main.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
)

`wasm_filter_integration_test` sent the request body straight after the
headers. Until the upstream connection is ready the upstream codec
filter holds the headers, and when it resumes it is given whatever body
an earlier filter has buffered so far (the buffer is shared by the
filter chain, see envoyproxy#48660). When that happened between two chunks of the
body, the upstream wasm filter that was buffering it no longer owned the
buffered data and failed
`ASSERT(parent_.state_.latest_data_decoding_filter_ == this)` on the
next chunk.

Send the body once the request headers have reached the upstream, so
that the codec filter is not waiting on the connection while the body
arrives.

Backport note: picked from the pull request ahead of its merge to main.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
)

`wasm_filter_integration_test` sent the request body straight after the
headers. Until the upstream connection is ready the upstream codec
filter holds the headers, and when it resumes it is given whatever body
an earlier filter has buffered so far (the buffer is shared by the
filter chain, see envoyproxy#48660). When that happened between two chunks of the
body, the upstream wasm filter that was buffering it no longer owned the
buffered data and failed
`ASSERT(parent_.state_.latest_data_decoding_filter_ == this)` on the
next chunk.

Send the body once the request headers have reached the upstream, so
that the codec filter is not waiting on the connection while the body
arrives.

Backport note: picked from the pull request ahead of its merge to main.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
)

`wasm_filter_integration_test` sent the request body straight after the
headers. Until the upstream connection is ready the upstream codec
filter holds the headers, and when it resumes it is given whatever body
an earlier filter has buffered so far (the buffer is shared by the
filter chain, see envoyproxy#48660). When that happened between two chunks of the
body, the upstream wasm filter that was buffering it no longer owned the
buffered data and failed
`ASSERT(parent_.state_.latest_data_decoding_filter_ == this)` on the
next chunk.

Send the body once the request headers have reached the upstream, so
that the codec filter is not waiting on the connection while the body
arrives.

Backport note: picked from the pull request ahead of its merge to main.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
)

`wasm_filter_integration_test` sent the request body straight after the
headers. Until the upstream connection is ready the upstream codec
filter holds the headers, and when it resumes it is given whatever body
an earlier filter has buffered so far (the buffer is shared by the
filter chain, see envoyproxy#48660). When that happened between two chunks of the
body, the upstream wasm filter that was buffering it no longer owned the
buffered data and failed
`ASSERT(parent_.state_.latest_data_decoding_filter_ == this)` on the
next chunk.

Send the body once the request headers have reached the upstream, so
that the codec filter is not waiting on the connection while the body
arrives.

Backport note: picked from the pull request ahead of its merge to main.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
)

`wasm_filter_integration_test` sent the request body straight after the
headers. Until the upstream connection is ready the upstream codec
filter holds the headers, and when it resumes it is given whatever body
an earlier filter has buffered so far (the buffer is shared by the
filter chain, see envoyproxy#48660). When that happened between two chunks of the
body, the upstream wasm filter that was buffering it no longer owned the
buffered data and failed
`ASSERT(parent_.state_.latest_data_decoding_filter_ == this)` on the
next chunk.

Send the body once the request headers have reached the upstream, so
that the codec filter is not waiting on the connection while the body
arrives.

Backport note: picked from the pull request ahead of its merge to main.

Signed-off-by: Ryan Northey <[email protected]>
wbpcode added a commit that referenced this pull request Nov 14, 2026
Commit Message: http: forward added trailers once from the filter
holding them

Fixes the filter manager's handling of trailers added by a filter
(`addDecodedTrailers()` /
`addEncodedTrailers()`):

- Response: when a filter after the adder stops iteration on the data
(e.g. one that buffers until
the end of the stream), `encodeData()` returned before dispatching the
added trailers, so that
filter and every filter after it never saw them and the response could
be held forever.
- Request: when a filter stopped on headers continues on the data, its
`commonContinue()`
dispatched the added trailers, and `decodeData()` dispatched them again
from the adder after the
loop, so later filters (including the router) decoded the trailers
twice.

The filter manager now records the single filter holding the trailers of
each direction: the
filter that added them, then each filter they reach, until they leave
the chain. Trailers are
forwarded once from the holder, and only while it iterates (at the end
of a data pass, when a
filter stopping on the data ends the pass, and when the holder resumes).
Trailers parked at a
filter that stopped all iteration are delivered to that filter once it
resumes.

Additional Description: Split out of #48660, where the same issues were
found; the fix does not
depend on per-filter buffers.
Risk Level: Medium
Testing: Unit tests + integration
Docs Changes: N/A
Release Notes: Added.
Runtime guard:
`envoy.reloadable_features.filter_manager_forward_held_trailers`

---------

Signed-off-by: wbpcode <[email protected]>
@wbpcode

wbpcode commented Nov 15, 2026

Copy link
Copy Markdown
Member Author

/retest

@wbpcode

wbpcode commented Nov 15, 2026 •

Copy link
Copy Markdown
Member Author

The latest version is ready for another review. Here is what changed since the last round.

Previous version: the shared buffer was removed entirely, and every filter got its own buffer. That only works if filters use the buffer APIs (decodingBuffer(), modifyDecodingBuffer(), addDecodedData(), etc.) exactly as intended. Those contracts are loosely defined, and even some in-tree extensions (e.g. grpc_web) don't follow them. So that version could silently break out-of-tree extensions.

Latest version: the shared buffer is kept and treated as a special per-filter buffer whose owner moves as data flows through the chain. The owner is always latest_data_decoding_filter_ / latest_data_encoding_filter_.

  • For the owner filter, every buffer API behaves exactly as it does today, so existing filters are unaffected.
  • For filters before the owner: in legacy shared-buffer mode, such a filter can't safely stop the chain and buffer again. Doing so is undefined behavior and leads to bugs. Now, when such a filter stops and buffers again, it gets its own buffer instance, so its data no longer mixes with the shared buffer further down the chain.

I still prefer the previous design because it is simpler and stricter. But this version is much safer for existing out-of-tree extensions, so I think it's the better trade-off for now.

BTW, I still split the per filter end_stream flag changes out into #49286. Review and merge them independently would make the picture easier to follow.

@agrawroh agrawroh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Suggested Fixes. Keeping the shared buffer with the latest filter and a passed filter's own buffer is the right shape, and probed accessor cases and the trailer blocker are fixed, but the redesign lets a stop-all filter strand a stopped filter.

  • 🚨 When a stop-all filter resumes before an earlier body holder, a holder right before it loses its buffer and end of stream, and its modifyDecodingBuffer() dereferences null in release builds.
  • ⚠️ With only the end-of-stream guard on, a filter that keeps the body, like the router with a retry policy, is handed it twice when a later buffering filter resumes before the filter holding the last frame.
  • 💡 This promises modifyDecodingBuffer() to a passed filter, while the header docs forbid it once data continues and the assert still requires the latest data filter.
  • 💡 No mode makes a filter that data has passed stop again, so the own-buffer path goes unmeasured, and no run turns the guards off.
  • 💡 The buffer-move watermark test never takes the total down to the low mark, so it passes with the move deferral removed.
  • 💡 The description still names observed_trailers_, says bufferedData() returns each filter's own buffer and lists one guard, which the redesign made untrue. Since it becomes the commit message, could it describe the shared-buffer design and both guards, with the risk rated High for a flow-control change?

The second finding sits in the end-of-stream change this PR shares with #49286, so #49286 can't safely land alone, and the two copies now conflict where they read the guards.

PerFilterBufferTracker::ActiveFilterScope buffer_scope(request_buffer_tracker_, **entry);
// If the filter pointed by entry has stopped for all frame types, return now.
if (handleDataIfStopAll(**entry, data, state_.decoder_filters_streaming_)) {
if (handleDataIfStopAll(**entry, data, state_.decoder_filters_streaming_, end_stream)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 When a stop-all filter resumes before an earlier body holder, a holder right before it loses its buffer and end of stream, and its modifyDecodingBuffer() dereferences null in release builds. A holder further back resends it, so a keeping router gets it twice. Could a park count as passing both ways, with filters past the latest data filter owning buffers?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch, another edge case. This problem actually also happens at main. But before per-filter-buffer, we presume multiple stops will break the filter chain anyway.
But we should fix this for per-filter-buffer. I will make it an independent PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A separate PR works for me, but since this one turns per-filter buffering on by default, could that fix land before this one merges?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#49485 covers data parked at the stop-all filter, but a holder of the only frame still loses its buffer and end of stream, and a holder further back still resends it to a filter that keeps the body, so could filters past the latest data filter own their buffers here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With every filter keeping its own buffer, a holder keeps its buffer and end of stream when a stop-all filter resumes first, and the new resume-order tests pin both orders.

Comment thread source/common/http/filter_manager.h Outdated
: filter_manager_callbacks_(filter_manager_callbacks), dispatcher_(dispatcher),
connection_(connection), stream_id_(stream_id), account_(std::move(account)),
proxy_100_continue_(proxy_100_continue),
per_filter_observed_end_stream_(ENVOY_RUNTIME_FEATURE_ENABLED(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ With only the end-of-stream guard on, a filter that keeps the body, like the router with a retry policy, is handed it twice when a later buffering filter resumes before the filter holding the last frame. Turning off the buffer guard lands here. Could per-position end of stream apply only when per-filter buffering is on?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, before per-filter-buffer support, any multiple stops presumably will break the filter chain. So, it's expected behaviour that the flag and buffer cannot works correctly at this scenario when the flag only. But the per-filter-end stream flag could help us to address other problems. So, I will inclined to keep them independent two runtime flag.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two flags are fine, but when the later filter stopped all iteration, the end-of-stream flag alone hands a keeping router the body twice where turning both off doesn’t, so could that mode avoid it before #49286 turns it on by default?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find a good way:
In the main, if a filter returned stop all, then another filter stopped the buffer. And the stop all resume the chain first, it will broken the chain anyway:

For A -> B -> C -> Router.

If the C returned stop all at the headers phase, then A stopped in the buffer phase, and if the C reused, the data will be send out and skip the processing of B. This is a broken scenario.


If you do worry about that and want an defensive result, I can merge two runtime flag, and mark it as default false in the #49286 and then flip the filter chain in this PR. By this way, we could merge the code more confidently step by step. WDYT?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging them into one flag that's off in #49286 and turned on here works for me, since per-position end of stream then never runs without per-filter buffering.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, defaulting the guard off in #49286 works for me, and the shared-buffer cases can land with per-filter buffering here before the flip.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With one guard now, per-position end of stream never runs without per-filter buffers, so this mode is gone.

that filter's own buffer, instead of in the single buffer shared by the whole stream, so a filter
can stop and buffer again after letting data through without mixing its data into data buffered
further down the chain. For such a filter, ``decodingBuffer()``, ``addDecodedData()`` and
``modifyDecodingBuffer()`` (and their encoding counterparts) operate on its own buffer; for all

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 This promises modifyDecodingBuffer() to a passed filter, while the header docs forbid it once data continues and the assert still requires the latest data filter. Could the note drop it, or the docs and assert allow it with a test?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The header docs and the assert now allow it under the guard, and the new modify tests cover it.

for (size_t i = 0; i < num_filters_; i++) {
const bool terminal = i == num_filters_ - 1;
const bool buffer = !terminal && ((mode_ != BufferMode::None && i == 0) ||
(mode_ == BufferMode::TwoFilters && i == num_filters_ / 2));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 No mode makes a filter that data has passed stop again, so the own-buffer path goes unmeasured, and no run turns the guards off. Could we add that mode and post numbers for both settings?

filter_manager_->destroyFilters();
}

TEST_F(FilterManagerPerFilterBufferTest, MovingBytesBetweenFilterBuffersKeepsWatermarkState) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 The buffer-move watermark test never takes the total down to the low mark, so it passes with the move deferral removed. With a 1-byte shared buffer and 6 bytes moving at a limit of 6, that mutant releases and re-pauses. Could the test use that shape?

wbpcode added a commit that referenced this pull request Nov 20, 2026
…ter (#49485)

Commit Message: http: record the stop-all filter data parks at as the
latest data filter

Additional Description:
When body data reaches a filter that returned StopAllIteration*, it
parks in that filter's buffer, but the latest data filter was only
recorded after the stop-all check, so it stayed at an earlier filter
that had already let those bytes through. That earlier filter could
still pass the modifyDecodingBuffer()/modifyEncodingBuffer() ownership
assert, while the filter actually holding the data could not.

This records the latest data filter at the top of the
decodeData()/encodeData() loop, before the stop-all and end_stream
checks. Recording a filter the data has already passed is a no-op, so
the only change is that a stop-all filter holding parked data becomes
the latest data filter.

This is also a prerequisite for #48660, where the latest data filter
decides which filter owns the shared buffer.

Risk Level: Low
Testing: unit tests (filter_manager_test, debug)
Docs Changes: N/A
Release Notes: N/A

Signed-off-by: wbpcode <[email protected]>
wbpcode added a commit that referenced this pull request Nov 22, 2026
…ager (#49286)

Commit Message: http: track observed end stream per filter position in
the filter manager
Additional Description: 
Split out of #48660.

The end_stream computed when a stopped filter resumes
(`commonContinue()`) previously read the stream-level
`observed_[de|en]code_end_stream_` flag, which records that the *codec*
has seen the end of the stream. For filters that hold data and re-inject
it (ext_proc style), that flag is positionally wrong: the end of the
stream may not have reached the resuming filter yet. #43175 fixed the
two-filter instance of this (#41654) by letting
`inject[De|En]codedDataToFilterChain()` rewrite the stream-level flag
under the runtime guard. That mechanism is last-writer-wins on a single
shared flag, which is only correct while there is one injecting filter
upstream of any resuming filter: with three or more stopping/injecting
filters, an upstream filter's final `inject(end_stream=true)` can land
between a mid-chain filter's injections and a downstream filter's
resume, making the downstream filter release buffered data with a
premature `end_stream=true` (truncating the remaining body).

Here is the A → B → C timeline:

| Step | Event | Stream-level flag | Actual state at each filter |
|---|---|---|---|
| 1 | The client's last chunk arrives with `end_stream=true` | **true**
(set by the codec) | A has the whole stream; nothing final has reached B
or C |
| 2 | A injects `(a1, false)` | **false** | B holds a1 and stops; A
still owes a2 |
| 3 | B's side stream answers a1 quickly, so B injects `(b1, false)` |
**false** | C receives b1, stops, and buffers it |
| 4 | A's side stream answers, so A injects `(a2, true)` | **true**
(written by A) | The frame stops at B, which holds a2 while it waits on
its side stream; **C never sees this frame** |
| 5 | C's async work finishes, so it calls `continueDecoding()` and then
`doData(observedEndStream() && ...)` | reads **true** | But B still owes
C the processed a2 (b2) |

This PR replaces the mechanism with a per-filter `observed_end_stream_`
marker: frame deliveries and parked frames latch it at the position they
actually reached, and the inject APIs author it at the injecting
filter's own position only. Resumption reads the resuming filter's own
marker, so the computation is correct for any number of
stopping/injecting filters. The stream-level flags are no longer
modified by data injection.

Risk Level: Medium
Testing: unit tests (filter_manager_test), ext_proc integration test
Docs Changes: N/A
Release Notes: added
Runtime guard:
envoy.reloadable_features.filter_manager_per_filter_observed_end_stream

---------

Signed-off-by: wbpcode <[email protected]>
@wbpcode
wbpcode force-pushed the dev-per-filter-buffering branch from 4ed1802 to 09904d4 Compare November 22, 2026 10:02
@wbpcode
wbpcode requested a review from mathetake as a code owner November 22, 2026 10:02
@wbpcode

wbpcode commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

I've switched this PR back to strict per-filter buffers, essentially the version @paul-r-gall approved earlier: every filter buffers only into its own buffer, and the shared stream buffer is no longer used when the runtime guard is enabled.

The hybrid version (shared buffer for some filters, own buffer for others) needed more rules every time we looked at it. Each round of review turned up a new case where data ended up in the wrong buffer when the latest data filter changed:

  • the earlier blocker;
  • the router losing its retry body when an injection made it the latest data filter;
  • filters that hadn't been reached by data yet replaying an earlier filter's bytes;
  • the cases found while trying to simplify the rule.

All of them came from filters switching between the shared buffer and their own buffer partway through a stream. Every fix added a condition, and passing tests only meant we hadn't found the next case. I couldn't say with confidence that all cases were covered, especially with out-of-tree filters calling these APIs in patterns we can't test.

The strict model is much simpler to reason about. A filter's buffer holds exactly the data stopped at that filter and is replayed starting at the next filter. Filters never switch buffers, so that whole class of bugs goes away.

It does have one known, documented behavior change: decodingBuffer()/encodingBuffer() return only the calling filter's own buffered data, not data buffered by other filters. I've updated the comments in envoy/http/filter.h and the dynamic modules ABI to describe it. In practice a filter rarely needs to read another filter's buffered body. I checked every in-tree caller: they all read data they buffered or added themselves, so none of them needs to change. Filters that do rely on this can adapt easily.

The guard envoy.reloadable_features.filter_manager_per_filter_buffer defaults to false for now, so out-of-tree extensions don't break silently. With the guard off, behavior is the same as main. We can flip the default once extension owners have had time to check their filters.

Other changes in this version:

  • With the guard on, the router drops its kept retry body once it gives up retrying on buffer overflow. Otherwise the kept body would hold the stream's total buffered bytes above the low watermark after an earlier filter applied backpressure, and downstream reads would never resume. This replaces router: drop the kept retry body once retries are given up on buffer overflow #49220, which I'm closing.
  • The PR is now a single commit on top of current main, so earlier inline comments may show as outdated. Sorry for the force-push; given how far the design moved, a clean diff seemed easier to review than a pile of incremental commits.

@agrawroh agrawroh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Suggested Fixes. Strict per-filter buffers are the right model, and in a local run with the guard defaulted on the HCM, router and 26 integration suites pass, but one router path can still stall a stream.

  • ⚠️ With the guard on, when a response ends retries before the request does, the router keeps its body, so after an earlier filter's watermark pause the total stays above half the limit and downstream reads stay disabled until a timeout or the stream end.
  • 💡 The router latches the guard on its own, not with the filter manager as its comment says, so a flip mid header read can give a shared-buffer stream a router that drains another filter's parked bytes.
  • 💡 With the guard on, a filter that only an earlier filter's replay reached has no buffer of its own, so its modifyDecodingBuffer() call dereferences null.
  • 💡 With the guard on, when the first body adder of a header-only request stops on headers, a body a later filter adds during the resume is never sent, while the shared buffer sends both.
  • 💡 With the guard on, a filter that returns StopIterationNoBuffer on a frame replayed from an earlier filter loses whatever it leaves there.
  • 💡 #49286 already added this guard with a bug-fix note for this release, so this reads as a new guard.
  • 💡 With the guard off every filter shares this stream buffer, so "owned by the latest filter that data has reached" describes the earlier design.
  • 💡 The guard-off integration case passes only while the response finishes inside the hold filter's 400 ms timer, and a 300 ms stall after the upstream end of stream makes it fail.
  • 💡 "Also fixes #46095" closes that issue on merge, while it still reproduces with the guard at its default. Could the description say the fix needs the guard?

Comment thread source/common/router/router.cc Outdated
buffering = false;
request_buffer_overflowed_ = true;

// Nothing reads the kept body once retries and redirects are given up, so drop it to release

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ With the guard on, when a response ends retries before the request does, the router keeps its body, so after an earlier filter's watermark pause the total stays above half the limit and downstream reads stay disabled until a timeout or the stream end. Could the router drop its kept body whenever it stops buffering?

Comment thread source/common/router/router.h Outdated
// Cached runtime flag value for reject_early_connect_data to avoid evaluating it on every data
// chunk.
bool reject_early_connect_data_enabled_ : 1 = false;
// Latched with the filter manager's per-filter buffer flag at stream creation. With per-filter

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 The router latches the guard on its own, not with the filter manager as its comment says, so a flip mid header read can give a shared-buffer stream a router that drains another filter's parked bytes. Could the drain follow the stream's latched mode, or run only when the buffer holds exactly what the router kept?

ASSERT(parent_.state_.latest_data_decoding_filter_ == this);
PerFilterBufferTracker::ActiveFilterScope buffer_scope(parent_.request_buffer_tracker_, *this);
// With per-filter buffer, the filter only modifies the data it holds itself.
ASSERT(parent_.per_filter_buffer_ || parent_.state_.latest_data_decoding_filter_ == this);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 With the guard on, a filter that only an earlier filter's replay reached has no buffer of its own, so its modifyDecodingBuffer() call dereferences null. Could both modify calls hit IS_ENVOY_BUG and return when the filter holds nothing?

Comment thread source/common/http/filter_manager.cc Outdated

const auto continue_iteration = (*entry)->commonHandleAfterHeadersCallback(status, end_stream);
if (per_filter_buffer_) {
coalesceBodyAddedInHeaders(continue_data_entry, entry, decoder_filters_.end());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 With the guard on, when the first body adder of a header-only request stops on headers, a body a later filter adds during the resume is never sent, while the shared buffer sends both. Could the resumed pass coalesce it into the resuming filter's buffer, as the inline pass does?

// whatever it left, as the codecs do for the data they dispatch. Otherwise data replayed
// from an earlier filter's buffer would stay there and be replayed again. A filter replayed
// its own buffer (after StopAll) keeps it: e.g. the router keeps the body there for retries.
if (parent_.per_filter_buffer_ && &provided_data != bufferedData().get()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 With the guard on, a filter that returns StopIterationNoBuffer on a frame replayed from an earlier filter loses whatever it leaves there. Could the status doc and the release note say so?

@@ -0,0 +1,11 @@
Added the runtime guard ``envoy.reloadable_features.filter_manager_per_filter_buffer``, disabled by

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 #49286 already added this guard with a bug-fix note for this release, so this reads as a new guard. Could the two notes become one, and say that filter_manager_forward_added_data_on_continue has no effect while this guard is on?

Comment thread source/common/http/filter_manager.h Outdated
// Buffer that body data stopped at this filter is buffered into, and that
// decodingBuffer()/encodingBuffer(), addDecodedData()/addEncodedData() and
// modifyDecodingBuffer()/modifyEncodingBuffer() operate on. This is the stream-level buffer
// shared by all filters, owned by the latest filter that data has reached. With per-filter

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 With the guard off every filter shares this stream buffer, so "owned by the latest filter that data has reached" describes the earlier design. Could the comment drop the ownership clause?

.getStringView());
}

TEST_P(FilterIntegrationTest, PerFilterBufferDisabledRequestBodyStillCompletes) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 The guard-off integration case passes only while the response finishes inside the hold filter's 400 ms timer, and a 300 ms stall after the upstream end of stream makes it fail. Could it wait on an event instead, or go, since the unit tests pin the shared path?

…med-header body coalescing, docs

Signed-off-by: wbpcode <[email protected]>
@wbpcode
wbpcode enabled auto-merge (squash) November 23, 2026 15:17
@wbpcode
wbpcode merged commit 6325aef into envoyproxy:main Nov 23, 2026
26 checks passed
@wbpcode
wbpcode deleted the dev-per-filter-buffering branch November 24, 2026 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants