(api-gateway) preserve PathPrefix when replacePrefixMatch is unset#23390
Merged
sujay-hashicorp merged 1 commit intomainfrom Mar 30, 2026
Merged
(api-gateway) preserve PathPrefix when replacePrefixMatch is unset#23390sujay-hashicorp merged 1 commit intomainfrom
sujay-hashicorp merged 1 commit intomainfrom
Conversation
50123cf to
39c50a4
Compare
39c50a4 to
a61f1ad
Compare
pajay-rao
approved these changes
Mar 27, 2026
7 tasks
Collaborator
|
📣 Hi @sujay-hashicorp! a backport is missing for this PR [23390] for versions [1.18,1.21] please perform the backport manually and add the following snippet to your backport PR description: |
rishabh-gupta-hashicorp
pushed a commit
that referenced
this pull request
Mar 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This change fixes the HTTPRoute
PathPrefixregression where Envoy strips the matched prefix even when no rewrite is configured.The regression came from the regex rewrite workaround added for
replacePrefixMatch: "/". That logic also treated an empty/unsetPrefixRewriteas a signal to strip the matched prefix, which changed the default behavior for plainPathPrefixroutes.With this change:
PrefixRewrite == "/"still uses the regex workaround introduced for the//issuePrefixRewrite == ""does not emit any rewritePrefixRewriteThis restores the original behavior for routes that only use
PathPrefix: the full incoming request path is forwarded upstream unchanged.Testing & Reproduction steps
Reproduction:
HTTPRoutewith aPathPrefixmatch such as/adminreplacePrefixMatch/URLRewrite/admin/master/consoleregexRewriteand the upstream receives/master/console/admin/master/consoleManual/behavior verification:
regexRewritePrefixRewrite == "/"still emit the regex-based rewrite workaroundPrefixRewriteTests run:
GOFLAGS=-mod=mod go test ./agent/xds -count=1 -run TestUserRewriteLogicGOFLAGS=-mod=mod go test ./agent/xds -count=1 -run TestAllResourcesFromSnapshotRelevant test updates:
regexRewriteoutputLinks
PR Checklist
PCI review checklist
I have documented a clear reason for, and description of, the change I am making.
If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
Revert plan: revert this PR to restore the previous rewrite behavior.
If applicable, I've documented the impact of any changes to security controls.
This change does not modify security controls.