Skip to content

Fix: regex path prase httproute#1604

Merged
npolshakova merged 4 commits intoagentgateway:mainfrom
Lasse4:fix-regex-path-prase-httproute
Apr 22, 2026
Merged

Fix: regex path prase httproute#1604
npolshakova merged 4 commits intoagentgateway:mainfrom
Lasse4:fix-regex-path-prase-httproute

Conversation

@Lasse4
Copy link
Copy Markdown
Contributor

@Lasse4 Lasse4 commented Apr 21, 2026

Description

Part of the Mentorship Program kgateway-dev/kgateway.dev#606
Issue: #1573

This PR fixes an issue where AgentGateway only supported literal HTTPRoute paths, while regex-based paths were not handled correctly. Regex path matching is now fully supported.

Comment on lines +39 to +40
- path:
pathPrefix: /
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks like it's translating out to a pathPrefix instead of the regex match. Did you run REFRESH_GOLDEN=true go test ./pkg/agentgateway/plugins to get the output section?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the HTTPRoute translator to correctly handle Gateway API RegularExpression path matches (notably patterns like ^/.*$), which previously broke due to leading-slash normalization intended for literal paths.

Changes:

  • Skip automatic leading "/" insertion when the HTTPRoute path match type is RegularExpression.
  • Add a new golden-test route YAML covering regex path matching.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
controller/pkg/agentgateway/translator/agw.go Adjusts path normalization to avoid corrupting regex patterns like ^/.*$.
controller/pkg/agentgateway/translator/testdata/routes/httproute-path-prefix-regex.yaml Adds golden-test coverage for regex path matching, but expected output needs regeneration/correction.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 71 to +75
dest := "/"
if match.Path.Value != nil && *match.Path.Value != "" {
dest = *match.Path.Value
}
if !strings.HasPrefix(dest, "/") {
dest = "/" + dest
if tp != gwv1.PathMatchRegularExpression {
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

The path normalization comment/behavior is now inconsistent: the code only enforces a leading "/" for non-regex path types, but the nearby comment still implies this applies universally. Update the comment to clarify that RegularExpression values are passed through without leading-slash coercion (to support patterns like "^/.*$").

Copilot uses AI. Check for mistakes.
@Lasse4 Lasse4 force-pushed the fix-regex-path-prase-httproute branch from 04dfe93 to 9733b8c Compare April 21, 2026 20:36
Lasse4 added 3 commits April 21, 2026 16:38
Signed-off-by: Lasse4 <lasse@vierow.de>
Signed-off-by: Lasse4 <lasse@vierow.de>
Signed-off-by: Lasse4 <lasse@vierow.de>
@Lasse4 Lasse4 force-pushed the fix-regex-path-prase-httproute branch from 9733b8c to 8f8d6da Compare April 21, 2026 20:38
Signed-off-by: Lasse4 <lasse@vierow.de>
@npolshakova npolshakova requested a review from Copilot April 22, 2026 14:37
@Lasse4 Lasse4 changed the title Draft: Fix: regex path prase httproute Fix: regex path prase httproute Apr 22, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +3
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

This test case exercises path.type: RegularExpression, but the filename suggests a PathPrefix match. Consider renaming the file (and any references, if applicable) to avoid confusion when scanning route test coverage.

Copilot uses AI. Check for mistakes.
@Lasse4 Lasse4 marked this pull request as ready for review April 22, 2026 14:55
@Lasse4 Lasse4 requested a review from a team as a code owner April 22, 2026 14:55
Copy link
Copy Markdown
Collaborator

@npolshakova npolshakova left a comment

Choose a reason for hiding this comment

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

Great job 🎉

@npolshakova npolshakova merged commit 3eddbc2 into agentgateway:main Apr 22, 2026
14 checks passed
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.

3 participants