Fix: regex path prase httproute#1604
Conversation
5cae94c to
04dfe93
Compare
| - path: | ||
| pathPrefix: / |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 isRegularExpression. - 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.
| dest := "/" | ||
| if match.Path.Value != nil && *match.Path.Value != "" { | ||
| dest = *match.Path.Value | ||
| } | ||
| if !strings.HasPrefix(dest, "/") { | ||
| dest = "/" + dest | ||
| if tp != gwv1.PathMatchRegularExpression { |
There was a problem hiding this comment.
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 "^/.*$").
04dfe93 to
9733b8c
Compare
Signed-off-by: Lasse4 <lasse@vierow.de>
Signed-off-by: Lasse4 <lasse@vierow.de>
9733b8c to
8f8d6da
Compare
Signed-off-by: Lasse4 <lasse@vierow.de>
There was a problem hiding this comment.
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.
| apiVersion: gateway.networking.k8s.io/v1 | ||
| kind: HTTPRoute | ||
| metadata: |
There was a problem hiding this comment.
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.
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.