Skip to content

Ext-Proc: Fixing data truncated issues with two filters in the chain - #43042

Closed
yanjunxiang-google wants to merge 16 commits into
envoyproxy:mainfrom
yanjunxiang-google:fix_two_ext_proc
Closed

yanjunxiang-google wants to merge 16 commits into
envoyproxy:mainfrom
yanjunxiang-google:fix_two_ext_proc

Conversation

@yanjunxiang-google

@yanjunxiang-google yanjunxiang-google commented Jan 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #41654

The root cause of the issue is when the 2nd filter resume the processing:

doData(observedEndStream() && !had_trailers_before_data);

, it is using an outdated observedEndStream() flag as end_of_stream. This flag is set to true once Envoy sees data with end_of_stream set to true either from downstream client or backend server. However, In the ext_proc case, after the data with end_of_stream=true is received by Envoy, it is sent out to the side-stream server and re-injected back to Envoy, the observedEndStream() flag has to be updated during re-injection. Otherwise, the 2nd filter commonContinue() deem the full body is in buffer, i.e, end_of_stream=true, even the 1st filter is still injecting more data.

The issue is reproduced in both ext_proc STREAMED and FULL_DUPLEX_STREAMED modes, also in both request and response directions. Please check the added integration tests.

@repokitteh-read-only

Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #43042 was opened by yanjunxiang-google.

see: more, trace.

Signed-off-by: Yanjun Xiang <[email protected]>
Signed-off-by: Yanjun Xiang <[email protected]>
Signed-off-by: Yanjun Xiang <[email protected]>
Signed-off-by: Yanjun Xiang <[email protected]>
Signed-off-by: Yanjun Xiang <[email protected]>
Signed-off-by: Yanjun Xiang <[email protected]>
Signed-off-by: Yanjun Xiang <[email protected]>
Signed-off-by: Yanjun Xiang <[email protected]>
@yanjunxiang-google

Copy link
Copy Markdown
Contributor Author

/assign @wbpcode @yanavlasov @tyxia

Signed-off-by: Yanjun Xiang <[email protected]>
@yanjunxiang-google

Copy link
Copy Markdown
Contributor Author

/retest

@tyxia

tyxia commented Feb 18, 2026 •

Copy link
Copy Markdown
Member

I just closed this PR since #43175 has been merged.

@yanjunxiang-google re-open if needed

@tyxia tyxia closed this Feb 18, 2026
botengyao pushed a commit to botengyao/envoy that referenced this pull request Feb 19, 2026
This is the 2nd attempt to fix
envoyproxy#41654.

The 1st attempt is envoyproxy#43042


The root cause of the issue is when the 2nd filter resume the
processing:


[envoy/source/common/http/filter_manager.cc](https://github.com/envoyproxy/envoy/blob/e45201c87d8481ecd72299139102d9ebf049cf75/source/common/http/filter_manager.cc#L132)

Line 132 in
[e45201c](envoyproxy@e45201c)

 doData(observedEndStream() && !had_trailers_before_data); 
, it is using an outdated observedEndStream() flag as end_of_stream.
This flag is set to true once Envoy sees data with end_of_stream set to
true either from downstream client or backend server. However, In the
ext_proc case, after the data with end_of_stream=true is received by
Envoy, it is sent out to the side-stream server and re-injected back to
Envoy, the observedEndStream() flag has to be updated during
re-injection. Otherwise, the 2nd filter commonContinue() deem the full
body is in buffer, i.e, end_of_stream=true, even the 1st filter is still
injecting more data.

The issue is reproduced in both ext_proc STREAMED and
FULL_DUPLEX_STREAMED modes, also in both request and response
directions. Please check the added integration tests.

---------

Signed-off-by: Yanjun Xiang <[email protected]>
Signed-off-by: Boteng Yao <[email protected]>
botengyao pushed a commit to botengyao/envoy that referenced this pull request Feb 20, 2026
This is the 2nd attempt to fix
envoyproxy#41654.

The 1st attempt is envoyproxy#43042


The root cause of the issue is when the 2nd filter resume the
processing:


[envoy/source/common/http/filter_manager.cc](https://github.com/envoyproxy/envoy/blob/e45201c87d8481ecd72299139102d9ebf049cf75/source/common/http/filter_manager.cc#L132)

Line 132 in
[e45201c](envoyproxy@e45201c)

 doData(observedEndStream() && !had_trailers_before_data); 
, it is using an outdated observedEndStream() flag as end_of_stream.
This flag is set to true once Envoy sees data with end_of_stream set to
true either from downstream client or backend server. However, In the
ext_proc case, after the data with end_of_stream=true is received by
Envoy, it is sent out to the side-stream server and re-injected back to
Envoy, the observedEndStream() flag has to be updated during
re-injection. Otherwise, the 2nd filter commonContinue() deem the full
body is in buffer, i.e, end_of_stream=true, even the 1st filter is still
injecting more data.

The issue is reproduced in both ext_proc STREAMED and
FULL_DUPLEX_STREAMED modes, also in both request and response
directions. Please check the added integration tests.

---------

Signed-off-by: Yanjun Xiang <[email protected]>
Signed-off-by: Boteng Yao <[email protected]>
botengyao pushed a commit to botengyao/envoy that referenced this pull request Feb 22, 2026
…a to filter chain (envoyproxy#43327)

Fix:  envoyproxy#43170

For details, please check:
envoyproxy#43042 (comment)

---------

Signed-off-by: Yanjun Xiang <[email protected]>
Signed-off-by: Boteng Yao <[email protected]>
phlax pushed a commit that referenced this pull request Feb 23, 2026
This is the 2nd attempt to fix
#41654.

The 1st attempt is #43042


The root cause of the issue is when the 2nd filter resume the
processing:


[envoy/source/common/http/filter_manager.cc](https://github.com/envoyproxy/envoy/blob/e45201c87d8481ecd72299139102d9ebf049cf75/source/common/http/filter_manager.cc#L132)

Line 132 in
[e45201c](e45201c)

 doData(observedEndStream() && !had_trailers_before_data); 
, it is using an outdated observedEndStream() flag as end_of_stream.
This flag is set to true once Envoy sees data with end_of_stream set to
true either from downstream client or backend server. However, In the
ext_proc case, after the data with end_of_stream=true is received by
Envoy, it is sent out to the side-stream server and re-injected back to
Envoy, the observedEndStream() flag has to be updated during
re-injection. Otherwise, the 2nd filter commonContinue() deem the full
body is in buffer, i.e, end_of_stream=true, even the 1st filter is still
injecting more data.

The issue is reproduced in both ext_proc STREAMED and
FULL_DUPLEX_STREAMED modes, also in both request and response
directions. Please check the added integration tests.

---------

Signed-off-by: Yanjun Xiang <[email protected]>
Signed-off-by: Boteng Yao <[email protected]>
phlax pushed a commit that referenced this pull request Feb 23, 2026
…a to filter chain (#43327)

Fix:  #43170

For details, please check:
#43042 (comment)

---------

Signed-off-by: Yanjun Xiang <[email protected]>
Signed-off-by: Boteng Yao <[email protected]>
nickshokri pushed a commit to nickshokri/envoy that referenced this pull request Mar 17, 2026
Fix filter interface doc.

Check:
envoyproxy#43042 (comment)
for context.

Signed-off-by: Yanjun Xiang <[email protected]>
Signed-off-by: nick <[email protected]>
nickshokri pushed a commit to nickshokri/envoy that referenced this pull request Mar 17, 2026
…a to filter chain (envoyproxy#43327)

Fix:  envoyproxy#43170

For details, please check:
envoyproxy#43042 (comment)

---------

Signed-off-by: Yanjun Xiang <[email protected]>
Signed-off-by: nick <[email protected]>
nickshokri pushed a commit to nickshokri/envoy that referenced this pull request Mar 17, 2026
This is the 2nd attempt to fix
envoyproxy#41654.

The 1st attempt is envoyproxy#43042

The root cause of the issue is when the 2nd filter resume the
processing:

[envoy/source/common/http/filter_manager.cc](https://github.com/envoyproxy/envoy/blob/e45201c87d8481ecd72299139102d9ebf049cf75/source/common/http/filter_manager.cc#L132)

Line 132 in
[e45201c](envoyproxy@e45201c)

 doData(observedEndStream() && !had_trailers_before_data);
, it is using an outdated observedEndStream() flag as end_of_stream.
This flag is set to true once Envoy sees data with end_of_stream set to
true either from downstream client or backend server. However, In the
ext_proc case, after the data with end_of_stream=true is received by
Envoy, it is sent out to the side-stream server and re-injected back to
Envoy, the observedEndStream() flag has to be updated during
re-injection. Otherwise, the 2nd filter commonContinue() deem the full
body is in buffer, i.e, end_of_stream=true, even the 1st filter is still
injecting more data.

The issue is reproduced in both ext_proc STREAMED and
FULL_DUPLEX_STREAMED modes, also in both request and response
directions. Please check the added integration tests.

---------

Signed-off-by: Yanjun Xiang <[email protected]>
Signed-off-by: nick <[email protected]>
nickshokri pushed a commit to nickshokri/envoy that referenced this pull request Mar 17, 2026
Fix filter interface doc.

Check:
envoyproxy#43042 (comment)
for context.

Signed-off-by: Yanjun Xiang <[email protected]>
Signed-off-by: nick <[email protected]>
nickshokri pushed a commit to nickshokri/envoy that referenced this pull request Mar 17, 2026
…a to filter chain (envoyproxy#43327)

Fix:  envoyproxy#43170

For details, please check:
envoyproxy#43042 (comment)

---------

Signed-off-by: Yanjun Xiang <[email protected]>
Signed-off-by: nick <[email protected]>
nickshokri pushed a commit to nickshokri/envoy that referenced this pull request Mar 17, 2026
This is the 2nd attempt to fix
envoyproxy#41654.

The 1st attempt is envoyproxy#43042

The root cause of the issue is when the 2nd filter resume the
processing:

[envoy/source/common/http/filter_manager.cc](https://github.com/envoyproxy/envoy/blob/e45201c87d8481ecd72299139102d9ebf049cf75/source/common/http/filter_manager.cc#L132)

Line 132 in
[e45201c](envoyproxy@e45201c)

 doData(observedEndStream() && !had_trailers_before_data);
, it is using an outdated observedEndStream() flag as end_of_stream.
This flag is set to true once Envoy sees data with end_of_stream set to
true either from downstream client or backend server. However, In the
ext_proc case, after the data with end_of_stream=true is received by
Envoy, it is sent out to the side-stream server and re-injected back to
Envoy, the observedEndStream() flag has to be updated during
re-injection. Otherwise, the 2nd filter commonContinue() deem the full
body is in buffer, i.e, end_of_stream=true, even the 1st filter is still
injecting more data.

The issue is reproduced in both ext_proc STREAMED and
FULL_DUPLEX_STREAMED modes, also in both request and response
directions. Please check the added integration tests.

---------

Signed-off-by: Yanjun Xiang <[email protected]>
Signed-off-by: nick <[email protected]>
fishcakez pushed a commit to fishcakez/envoy that referenced this pull request Mar 25, 2026
Fix filter interface doc.

Check:
envoyproxy#43042 (comment)
for context.

Signed-off-by: Yanjun Xiang <[email protected]>
fishcakez pushed a commit to fishcakez/envoy that referenced this pull request Mar 25, 2026
fishcakez pushed a commit to fishcakez/envoy that referenced this pull request Mar 25, 2026
This is the 2nd attempt to fix
envoyproxy#41654.

The 1st attempt is envoyproxy#43042


The root cause of the issue is when the 2nd filter resume the
processing:


[envoy/source/common/http/filter_manager.cc](https://github.com/envoyproxy/envoy/blob/e45201c87d8481ecd72299139102d9ebf049cf75/source/common/http/filter_manager.cc#L132)

Line 132 in
[e45201c](envoyproxy@e45201c)

 doData(observedEndStream() && !had_trailers_before_data); 
, it is using an outdated observedEndStream() flag as end_of_stream.
This flag is set to true once Envoy sees data with end_of_stream set to
true either from downstream client or backend server. However, In the
ext_proc case, after the data with end_of_stream=true is received by
Envoy, it is sent out to the side-stream server and re-injected back to
Envoy, the observedEndStream() flag has to be updated during
re-injection. Otherwise, the 2nd filter commonContinue() deem the full
body is in buffer, i.e, end_of_stream=true, even the 1st filter is still
injecting more data.

The issue is reproduced in both ext_proc STREAMED and
FULL_DUPLEX_STREAMED modes, also in both request and response
directions. Please check the added integration tests.

---------

Signed-off-by: Yanjun Xiang <[email protected]>
krinkinmu pushed a commit to grnmeira/envoy that referenced this pull request Apr 20, 2026
Fix filter interface doc.

Check:
envoyproxy#43042 (comment)
for context.

Signed-off-by: Yanjun Xiang <[email protected]>
krinkinmu pushed a commit to grnmeira/envoy that referenced this pull request Apr 20, 2026
krinkinmu pushed a commit to grnmeira/envoy that referenced this pull request Apr 20, 2026
This is the 2nd attempt to fix
envoyproxy#41654.

The 1st attempt is envoyproxy#43042


The root cause of the issue is when the 2nd filter resume the
processing:


[envoy/source/common/http/filter_manager.cc](https://github.com/envoyproxy/envoy/blob/e45201c87d8481ecd72299139102d9ebf049cf75/source/common/http/filter_manager.cc#L132)

Line 132 in
[e45201c](envoyproxy@e45201c)

 doData(observedEndStream() && !had_trailers_before_data); 
, it is using an outdated observedEndStream() flag as end_of_stream.
This flag is set to true once Envoy sees data with end_of_stream set to
true either from downstream client or backend server. However, In the
ext_proc case, after the data with end_of_stream=true is received by
Envoy, it is sent out to the side-stream server and re-injected back to
Envoy, the observedEndStream() flag has to be updated during
re-injection. Otherwise, the 2nd filter commonContinue() deem the full
body is in buffer, i.e, end_of_stream=true, even the 1st filter is still
injecting more data.

The issue is reproduced in both ext_proc STREAMED and
FULL_DUPLEX_STREAMED modes, also in both request and response
directions. Please check the added integration tests.

---------

Signed-off-by: Yanjun Xiang <[email protected]>
jwendell pushed a commit to jwendell/envoy that referenced this pull request Aug 25, 2026
…a to filter chain (envoyproxy#43327)

Fix:  envoyproxy#43170

For details, please check:
envoyproxy#43042 (comment)

---------

Signed-off-by: Yanjun Xiang <[email protected]>
Signed-off-by: Boteng Yao <[email protected]>
(cherry picked from commit 29c13db)
Signed-off-by: Jonh Wendell <[email protected]>
jwendell pushed a commit to jwendell/envoy that referenced this pull request Aug 25, 2026
Backport to release/v1.36 of envoyproxy#43175. This is a cherry-pick of the
release/v1.37 commit 567847a, which in
turn cherry-picked the main-branch commit
867251a.

This is the 2nd attempt to fix
envoyproxy#41654.

The 1st attempt is envoyproxy#43042

The root cause of the issue is when the 2nd filter resume the
processing, `doData(observedEndStream() && !had_trailers_before_data)`
in `source/common/http/filter_manager.cc` uses an outdated
`observedEndStream()` flag as `end_of_stream`. This flag is set to true
once Envoy sees data with end_of_stream set to true either from
downstream client or backend server. However, in the ext_proc case,
after the data with end_of_stream=true is received by Envoy, it is sent
out to the side-stream server and re-injected back to Envoy, the
`observedEndStream()` flag has to be updated during re-injection.
Otherwise, the 2nd filter `commonContinue()` deems the full body is in
buffer, i.e. end_of_stream=true, even the 1st filter is still injecting
more data.

The issue is reproduced in both ext_proc STREAMED and
FULL_DUPLEX_STREAMED modes, also in both request and response
directions. Please check the added integration tests.

Backport notes (changes needed to resolve conflicts against 1.36):

- Changelog: 1.36 uses the fragment-directory format, so the
  `changelogs/current.yaml` entry was converted to
  `changelogs/current/bug_fixes/ext_proc__support-two-ext-proc-filters.rst`.
- `source/common/runtime/runtime_features.cc`: only added the
  `envoy.reloadable_features.ext_proc_inject_data_with_state_update`
  guard; the unrelated `ext_proc_stream_close_optimization` guard does
  not exist on 1.36 and was dropped from the surrounding context.
- `ext_proc_integration_common.cc`: wrapped 1.36's existing
  `composite_test_`/`downstream_filter` config setup in the new
  `if (!two_ext_proc_filters_)` guard rather than the 1.37
  `config_option.filter_setup` enum, which does not exist on 1.36.
- `filter_test.cc`: 1.36 keeps `HttpFilterTest` in
  `filter_test_common.*`; the real change (setting the runtime guard in
  `initialize()`) applies only to `filter_test_common.cc`.
- `filter_test_common.h`/`BUILD`: added the `scoped_runtime_`
  (`TestScopedRuntime`) member, its `test_runtime.h` include and the
  `//test/test_common:test_runtime_lib` dep, none of which existed on
  1.36.
- `ext_proc_full_duplex_integration_test.cc`: kept the three new
  `TwoExtProcFilters*` tests and dropped the 1.37-only
  `ServerWaitforEnvoyHalfCloseThenCloseStream` test (not part of this
  change; depends on the 1.37-only `ext_proc_graceful_grpc_close`
  feature).
- Fuzzer: kept only the `ext_proc_inject_data_with_state_update` runtime
  override; the 1.37-only `input.response()` size guard was dropped.

Signed-off-by: Yanjun Xiang <[email protected]>
Signed-off-by: Boteng Yao <[email protected]>
Signed-off-by: Jonh Wendell <[email protected]>
jwendell pushed a commit that referenced this pull request Aug 26, 2026
…a to filter chain (#43327)

Fix:  #43170

For details, please check:
#43042 (comment)

---------

Signed-off-by: Yanjun Xiang <[email protected]>
Signed-off-by: Boteng Yao <[email protected]>
(cherry picked from commit 29c13db)
Signed-off-by: Jonh Wendell <[email protected]>
jwendell pushed a commit that referenced this pull request Aug 26, 2026
Backport to release/v1.36 of #43175. This is a cherry-pick of the
release/v1.37 commit 567847a, which in
turn cherry-picked the main-branch commit
867251a.

This is the 2nd attempt to fix
#41654.

The 1st attempt is #43042

The root cause of the issue is when the 2nd filter resume the
processing, `doData(observedEndStream() && !had_trailers_before_data)`
in `source/common/http/filter_manager.cc` uses an outdated
`observedEndStream()` flag as `end_of_stream`. This flag is set to true
once Envoy sees data with end_of_stream set to true either from
downstream client or backend server. However, in the ext_proc case,
after the data with end_of_stream=true is received by Envoy, it is sent
out to the side-stream server and re-injected back to Envoy, the
`observedEndStream()` flag has to be updated during re-injection.
Otherwise, the 2nd filter `commonContinue()` deems the full body is in
buffer, i.e. end_of_stream=true, even the 1st filter is still injecting
more data.

The issue is reproduced in both ext_proc STREAMED and
FULL_DUPLEX_STREAMED modes, also in both request and response
directions. Please check the added integration tests.

Backport notes (changes needed to resolve conflicts against 1.36):

- Changelog: 1.36 uses the fragment-directory format, so the
  `changelogs/current.yaml` entry was converted to
  `changelogs/current/bug_fixes/ext_proc__support-two-ext-proc-filters.rst`.
- `source/common/runtime/runtime_features.cc`: only added the
  `envoy.reloadable_features.ext_proc_inject_data_with_state_update`
  guard; the unrelated `ext_proc_stream_close_optimization` guard does
  not exist on 1.36 and was dropped from the surrounding context.
- `ext_proc_integration_common.cc`: wrapped 1.36's existing
  `composite_test_`/`downstream_filter` config setup in the new
  `if (!two_ext_proc_filters_)` guard rather than the 1.37
  `config_option.filter_setup` enum, which does not exist on 1.36.
- `filter_test.cc`: 1.36 keeps `HttpFilterTest` in
  `filter_test_common.*`; the real change (setting the runtime guard in
  `initialize()`) applies only to `filter_test_common.cc`.
- `filter_test_common.h`/`BUILD`: added the `scoped_runtime_`
  (`TestScopedRuntime`) member, its `test_runtime.h` include and the
  `//test/test_common:test_runtime_lib` dep, none of which existed on
  1.36.
- `ext_proc_full_duplex_integration_test.cc`: kept the three new
  `TwoExtProcFilters*` tests and dropped the 1.37-only
  `ServerWaitforEnvoyHalfCloseThenCloseStream` test (not part of this
  change; depends on the 1.37-only `ext_proc_graceful_grpc_close`
  feature).
- Fuzzer: kept only the `ext_proc_inject_data_with_state_update` runtime
  override; the 1.37-only `input.response()` size guard was dropped.

Signed-off-by: Yanjun Xiang <[email protected]>
Signed-off-by: Boteng Yao <[email protected]>
Signed-off-by: Jonh Wendell <[email protected]>
jwendell added a commit to envoyproxy/envoy-openssl that referenced this pull request Sep 15, 2026
Backport to release/v1.35 of #43175. This is a cherry-pick of the
release/v1.36 commit ac77ca1, which in
turn cherry-picked the release/v1.37 commit
567847a5ed947b0ae3a6f10ecefb0b9ac8c17605, itself a cherry-pick of the
main-branch commit 867251ab48bb4fda89ead154bbc600131cf614ad.

This is the 2nd attempt to fix
envoyproxy/envoy#41654.

The 1st attempt is envoyproxy/envoy#43042

The root cause of the issue is when the 2nd filter resume the
processing, `doData(observedEndStream() && !had_trailers_before_data)`
in `source/common/http/filter_manager.cc` uses an outdated
`observedEndStream()` flag as `end_of_stream`. This flag is set to true
once Envoy sees data with end_of_stream set to true either from
downstream client or backend server. However, in the ext_proc case,
after the data with end_of_stream=true is received by Envoy, it is sent
out to the side-stream server and re-injected back to Envoy, the
`observedEndStream()` flag has to be updated during re-injection.
Otherwise, the 2nd filter `commonContinue()` deems the full body is in
buffer, i.e. end_of_stream=true, even the 1st filter is still injecting
more data.

The issue is reproduced in both ext_proc STREAMED and
FULL_DUPLEX_STREAMED modes, also in both request and response
directions. Please check the added integration tests.

Backport notes (changes needed to resolve conflicts against 1.35):

- The source fix (filter_manager.cc, processor_state.cc) and the
  `envoy.reloadable_features.ext_proc_inject_data_with_state_update`
  runtime guard applied cleanly; the unrelated
  `generic_proxy_codec_buffer_limit` guard in the surrounding context
  does not exist on 1.35 and was dropped.
- 1.35 predates the 1.36 ext_proc test refactor, so it has no
  `ext_proc_integration_common.*`, `filter_test_common.*` or
  `ext_proc_full_duplex_integration_test.cc`. The new files the
  cherry-pick tried to add were dropped, and all test changes were
  ported into 1.35's monolithic `ext_proc_integration_test.cc` and
  `filter_test.cc` instead: the runtime-guard override in the config
  setup, the `two_ext_proc_filters_` config path and its helpers
  (`addDownstreamExtProcFilter`, `server1*` gRPC helpers), the extracted
  `initializeConfigDuplexStreamed`, and the three new `TwoExtProcFilters*`
  full-duplex tests plus the two STREAMED tests.
- 1.35 lacks the `ContainsHeader` matcher, so the ported tests use the
  equivalent `SingleHeaderValueIs` matcher already imported in the file.
- The 1.37-only `DuplexStreamedServerResponseWithSynthesizedTrailer` test
  is disabled (renamed `DISABLED_*`); it depends on behavior not present
  on 1.35.
- Fuzzer: kept only the `ext_proc_inject_data_with_state_update` runtime
  override.

Co-authored-by: Claude Opus 4.8 <[email protected]>
jwendell added a commit to envoyproxy/envoy-openssl that referenced this pull request Sep 23, 2026
…#620)

Backport to release/v1.34 of #43175. This is a cherry-pick of the
release/v1.35 commit 05ae42b, which in
turn backported the release/v1.36 commit
ac77ca1, itself a cherry-pick of the
release/v1.37 commit 567847a5ed947b0ae3a6f10ecefb0b9ac8c17605, itself a
cherry-pick of the main-branch commit
867251ab48bb4fda89ead154bbc600131cf614ad.

This is the 2nd attempt to fix
envoyproxy/envoy#41654.

The 1st attempt is envoyproxy/envoy#43042

The root cause of the issue is when the 2nd filter resume the
processing, `doData(observedEndStream() && !had_trailers_before_data)`
in `source/common/http/filter_manager.cc` uses an outdated
`observedEndStream()` flag as `end_of_stream`. This flag is set to true
once Envoy sees data with end_of_stream set to true either from
downstream client or backend server. However, in the ext_proc case,
after the data with end_of_stream=true is received by Envoy, it is sent
out to the side-stream server and re-injected back to Envoy, the
`observedEndStream()` flag has to be updated during re-injection.
Otherwise, the 2nd filter `commonContinue()` deems the full body is in
buffer, i.e. end_of_stream=true, even the 1st filter is still injecting
more data.

The issue is reproduced in both ext_proc STREAMED and
FULL_DUPLEX_STREAMED modes, also in both request and response
directions. Please check the added integration tests.

Backport notes (changes needed to resolve conflicts against 1.34):

- The source fix (filter_manager.cc, processor_state.cc) applied
  cleanly.
- runtime_features.cc: kept 1.34's existing ext_proc guards and inserted
  only the new
  `envoy.reloadable_features.ext_proc_inject_data_with_state_update`
  guard alphabetically; the 1.35-only `ext_proc_fail_close_spurious_resp`
  context guard does not exist on 1.34 and was dropped.
- All test changes were ported into 1.34's monolithic
  `ext_proc_integration_test.cc`: the `two_ext_proc_filters_` config
  path and its helpers (`addDownstreamExtProcFilter`, `server1*` gRPC
  helpers), the extracted `initializeConfigDuplexStreamed`, the renamed
  header/body helpers, and the five new `TwoExtProcFilters*` tests.
- The `ServerSendOutOfOrderResponseDuplexStreamed` test kept 1.34's own
  400-response behavior; only the mechanical helper renames were applied
  (the 1.35 500-response variant was not adopted).
- The 1.35-only tests that appeared in the conflict but are unrelated to
  this feature (`DISABLED_DuplexStreamedServerResponseWithSynthesizedTrailer`,
  `BufferedModeOverSizeRequestLocalReply`,
  `FilterStateAccessLogSerialization`, and the other Pack*/*Trailers*
  tests) belong to other commits not backported to 1.34 and were dropped.

Signed-off-by: Jonh Wendell <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
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.

ext_proc: FULL DUPLEX STREAMED response body truncated when multiple filters defined

4 participants