Skip to content

fix: prevent configuring requestMirror filter and directResponse/RequestRedirect filter together#7474

Merged
zhaohuabing merged 3 commits intoenvoyproxy:mainfrom
zhaohuabing:fix-7473
Dec 15, 2025
Merged

fix: prevent configuring requestMirror filter and directResponse/RequestRedirect filter together#7474
zhaohuabing merged 3 commits intoenvoyproxy:mainfrom
zhaohuabing:fix-7473

Conversation

@zhaohuabing
Copy link
Copy Markdown
Member

@zhaohuabing zhaohuabing commented Nov 10, 2025

Fixes #7473
Release Notes: Yes

@zhaohuabing zhaohuabing requested a review from a team as a code owner November 10, 2025 07:56
@zhaohuabing zhaohuabing marked this pull request as draft November 10, 2025 07:56
@zhaohuabing zhaohuabing changed the title fix: mirror filter can't be used with direct response fix: prevent configuring requestMirror filter and directResponse filter together Nov 10, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.32%. Comparing base (343aeb3) to head (7abab91).
⚠️ Report is 470 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7474      +/-   ##
==========================================
- Coverage   72.42%   72.32%   -0.10%     
==========================================
  Files         234      234              
  Lines       34538    34550      +12     
==========================================
- Hits        25013    24988      -25     
- Misses       7737     7768      +31     
- Partials     1788     1794       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

cnvergence
cnvergence previously approved these changes Nov 10, 2025
@zhaohuabing zhaohuabing force-pushed the fix-7473 branch 2 times, most recently from 07b6933 to 1983322 Compare November 11, 2025 02:13
@zhaohuabing zhaohuabing changed the title fix: prevent configuring requestMirror filter and directResponse filter together fix: prevent configuring requestMirror filter and directResponse/RequestRedirect filter together Nov 11, 2025
@zhaohuabing zhaohuabing force-pushed the fix-7473 branch 3 times, most recently from cd6cef5 to 66471dc Compare November 17, 2025 12:41
cnvergence
cnvergence previously approved these changes Nov 17, 2025
@cnvergence
Copy link
Copy Markdown
Member

/retest

name: gateway-1
sectionName: http
rules:
- matches:
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.

can we add a mixed rule case, where one rule is valid and one isnt, to make sure the valid rule is not impacted

Copy link
Copy Markdown
Member Author

@zhaohuabing zhaohuabing Nov 18, 2025

Choose a reason for hiding this comment

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

According to the Gateway API specific, The HTTPRouteAccepted condition should be set to false with IncompatibleFilters reason when there are incompatible filters present on a route rule.

https://github.com/kubernetes-sigs/gateway-api/blob/f24f3a61f398c65ab629da1843cb65fd5ec9419f/apis/v1/shared_types.go#L384-L387

And EG skips the HTTPRoutes with Accepted status as False, which is reasonable as the entire HTTPRoute has been rejected.

if parentRef.HasCondition(httpRoute, gwapiv1.RouteConditionAccepted, metav1.ConditionFalse) {
continue
}

Copy link
Copy Markdown
Member Author

@zhaohuabing zhaohuabing Nov 18, 2025

Choose a reason for hiding this comment

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

Checked the Gateway API spec again, it seems that we should set Accepted as true as long as at least one rule is valid and implemented, even if some other rules in the same HTTPRoute are invalid.

// A Route MUST be considered "Accepted" if at least one of the Route's
// rules is implemented by the Gateway.

Changing this behavior would require a global update and could affect other cases as well. We'd better handle it in a separate PR. If we agree on this, I can raise a PR to address it first.

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.

yeah can we tackle this as part of #7545 and then start adding more fail fast cases

Copy link
Copy Markdown
Member Author

@zhaohuabing zhaohuabing Dec 3, 2025

Choose a reason for hiding this comment

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

@arkodg the translation for mixed valid and invalid rules has been addressed in #7625, and this one is ready for review whenever you have a moment.

@zhaohuabing zhaohuabing requested a review from arkodg November 18, 2025 06:39
@zhaohuabing zhaohuabing marked this pull request as draft November 18, 2025 06:40
@zhaohuabing zhaohuabing force-pushed the fix-7473 branch 3 times, most recently from 3248085 to 88321e2 Compare December 3, 2025 10:53
@zhaohuabing zhaohuabing marked this pull request as ready for review December 3, 2025 10:53
@zhaohuabing zhaohuabing requested review from a team and cnvergence December 3, 2025 10:53
@zhaohuabing zhaohuabing added this to the v1.7.0-rc.1 Release milestone Dec 11, 2025
@arkodg
Copy link
Copy Markdown
Contributor

arkodg commented Dec 11, 2025

worth adding a release note around breaking change, something like

  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /foo
    filters:
    - type: RequestRedirect
      requestRedirect:
        scheme: https
        statusCode: 302
    - type: ResponseHeaderModifier
      responseHeaderModifier:
        add:
        - name: X-Bad
          value: "bad\nvalue"   # invalid per HeaderValueRegexp

will no longer work

@zhaohuabing
Copy link
Copy Markdown
Member Author

worth adding a release note around breaking change, something like

  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /foo
    filters:
    - type: RequestRedirect
      requestRedirect:
        scheme: https
        statusCode: 302
    - type: ResponseHeaderModifier
      responseHeaderModifier:
        add:
        - name: X-Bad
          value: "bad\nvalue"   # invalid per HeaderValueRegexp

will no longer work

I might be missing somthing, but this PR doesn't touch the code for responseHeaderModifier validation logic.

There is already a release note for the breaking change introduced in this PR:

 Set HTTPRoute Accepted status to False when RequestMirror filter is used together with DirectResponse or RequestRedirect filters.
 

@arkodg arkodg requested review from a team December 14, 2025 07:19
…ether

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

check redirect respose filter

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
@zhaohuabing zhaohuabing merged commit 92d2a1a into envoyproxy:main Dec 15, 2025
50 of 55 checks passed
@zhaohuabing zhaohuabing deleted the fix-7473 branch December 15, 2025 08:33
millermatt pushed a commit to millermatt/envoy-gateway that referenced this pull request Jan 4, 2026
…estRedirect filter together (envoyproxy#7474)

* fix: prevent configuring RequestMirror and DirectResponse filters together

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

check redirect respose filter

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

* address comments

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

* fix lint

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

---------

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Matt Miller <millermatt@outlook.com>
rudrakhp pushed a commit to rudrakhp/gateway that referenced this pull request Apr 15, 2026
…estRedirect filter together (envoyproxy#7474)

* fix: prevent configuring RequestMirror and DirectResponse filters together

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

check redirect respose filter

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

* address comments

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

* fix lint

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

---------

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
rudrakhp added a commit that referenced this pull request Apr 16, 2026
* fix: avoid metric increments on no-op delete reconcile paths (#8480)

* fix: avoid metric increments on no-op delete reconcile paths

Signed-off-by: Felipe Sabadini Facina <fsabadini@hotmail.com>

* Update internal/infrastructure/kubernetes/infra_resource_test.go

Signed-off-by: Isaac Wilson <isaac.wilson514@gmail.com>

* Update internal/infrastructure/kubernetes/infra_resource_test.go

Signed-off-by: Isaac Wilson <isaac.wilson514@gmail.com>

---------

Signed-off-by: Felipe Sabadini Facina <fsabadini@hotmail.com>
Signed-off-by: Isaac Wilson <isaac.wilson514@gmail.com>
Co-authored-by: Isaac Wilson <isaac.wilson514@gmail.com>
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>

* fix: restore failure-path metric recording for delete and HPA reconcile (#8656)

Fixes #8651

Signed-off-by: Felipe Sabadini Facina <fsabadini@hotmail.com>
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>

* fix: helm secrets rbac for gateway namespace with watch list of namespaces (#8706)

* fix: helm secrets rbac for gateway namespace with watch list of namespaces

Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>

* add release notes

Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>

* review update

Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>

---------

Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
Co-authored-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>

* fix: handle network errors in rate limit e2e tests (#8446)

Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>

* fix: propagate the HTTPFilter translation errors to the outer layer (#7556)

* progate the HTTPFilter validation errors to the outer layer

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>

* fix: return 500 error for invalid filters (#7605)

return 500 error for invalid filters

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>

* fix: prevent configuring requestMirror filter and directResponse/RequestRedirect filter together (#7474)

* fix: prevent configuring RequestMirror and DirectResponse filters together

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

check redirect respose filter

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

* address comments

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

* fix lint

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

---------

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>

* fix bug with grpcroute mirror filter (#8541)

* fix bug with grpcroute mirror filter

Signed-off-by: Adam Buran <aburan@roblox.com>

* add indexers test

Signed-off-by: Adam Buran <aburan@roblox.com>

* add release note

Signed-off-by: Adam Buran <aburan@roblox.com>

---------

Signed-off-by: Adam Buran <aburan@roblox.com>
Signed-off-by: Arko Dasgupta <arkodg@users.noreply.github.com>
Co-authored-by: Arko Dasgupta <arkodg@users.noreply.github.com>
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>

* fix: normalize CRLF line endings in htpasswd basic auth secrets (#8557)

Fixes #8554

Signed-off-by: stekole <stefan@sandnetworks.com>
Signed-off-by: stekole <30674956+stekole@users.noreply.github.com>
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>

* fix: status for mirror backend (#8675)

Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>

* fix: set HTTPRoute Accepted condition as true with mixed invalid and valid rules (#7625)

* set HTTPRoute Accepted condition as true with mixed invalid and valid rules

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>

* fix: basic auth validation (#8053)

* fix basic auth validation

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>

* [release/v1.6] fix gen check

Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>

---------

Signed-off-by: Felipe Sabadini Facina <fsabadini@hotmail.com>
Signed-off-by: Isaac Wilson <isaac.wilson514@gmail.com>
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Adam Buran <aburan@roblox.com>
Signed-off-by: Arko Dasgupta <arkodg@users.noreply.github.com>
Signed-off-by: stekole <stefan@sandnetworks.com>
Signed-off-by: stekole <30674956+stekole@users.noreply.github.com>
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Co-authored-by: Felipe Sabadini <fsabadini@hotmail.com>
Co-authored-by: Isaac Wilson <isaac.wilson514@gmail.com>
Co-authored-by: Karol Szwaj <karol.szwaj@gmail.com>
Co-authored-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Co-authored-by: aburanrbx <aburan@roblox.com>
Co-authored-by: Arko Dasgupta <arkodg@users.noreply.github.com>
Co-authored-by: stekole <30674956+stekole@users.noreply.github.com>
Co-authored-by: Kota Kimura <86363983+kkk777-7@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RequestMirror silently fails when HTTPRoute is configured with a filter with direct response

5 participants