Skip to content

networking: add pathTemplate match type to StringMatch#3675

Open
AntonioMorales97 wants to merge 1 commit intoistio:masterfrom
AntonioMorales97:networking/virtualservice-path-template
Open

networking: add pathTemplate match type to StringMatch#3675
AntonioMorales97 wants to merge 1 commit intoistio:masterfrom
AntonioMorales97:networking/virtualservice-path-template

Conversation

@AntonioMorales97
Copy link

Description

Add a new pathTemplate oneof variant to StringMatch to support URI template path matching in VirtualService HTTPMatchRequest.uri.

This allows matching patterns like /users/{*}/orders without resorting to regex:

apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
  name: example
spec:
  hosts:
  - example.com
  http:
  - match:
    - uri:
        pathTemplate: "/users/{*}/orders"
    route:
    - destination:
        host: orders-service
  • {*} matches exactly one path segment
  • {**} matches one or more path segments (must be the last operator)

Backed by Envoy's UriTemplateMatchConfig extension, the same mechanism already used for AuthorizationPolicy path matching.

Motivation

  • Consistency: AuthorizationPolicy already supports {*}/{**} path templates (#47306); VirtualService should too
  • Simplicity: more readable and less error-prone than equivalent regex for REST API patterns
  • Performance: avoids regex evaluation overhead

Related

The implementation in istio/istio is submitted as a dependent PR and will be linked once this merges.

Add a new pathTemplate oneof variant to StringMatch to support URI
template path matching in VirtualService HTTPMatchRequest. This uses
{*} to match a single path segment and {**} to match one or more
segments, backed by Envoy's UriTemplateMatchConfig extension.

This is consistent with the existing path template support in
AuthorizationPolicy (issue #47306).

Closes #59533

Signed-off-by: Antonio <antoniomorales9711@gmail.com>
@AntonioMorales97 AntonioMorales97 requested a review from a team as a code owner March 19, 2026 13:16
@istio-policy-bot
Copy link

🤔 🐛 You appear to be fixing a bug in Go code, yet your PR doesn't include updates to any test files. Did you forget to add a test?

Courtesy of your friendly test nag.

@istio-policy-bot
Copy link

😊 Welcome @AntonioMorales97! This is either your first contribution to the Istio api repo, or it's been
a while since you've been here.

You can learn more about the Istio working groups, Code of Conduct, and contribution guidelines
by referring to Contributing to Istio.

Thanks for contributing!

Courtesy of your friendly welcome wagon.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Mar 19, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: AntonioMorales97 / name: Antonio Morales (fbdb857)

@istio-testing istio-testing added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. needs-ok-to-test labels Mar 19, 2026
@istio-testing
Copy link
Collaborator

Hi @AntonioMorales97. Thanks for your PR.

I'm waiting for a istio member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

AntonioMorales97 added a commit to AntonioMorales97/istio that referenced this pull request Mar 19, 2026
Add support for the pathTemplate match type in VirtualService
HTTPMatchRequest.uri, using Envoy's URI template path matching
extension (UriTemplateMatchConfig). This is consistent with the
existing path template support in AuthorizationPolicy.

- Route conversion: StringMatch_PathTemplate maps to
  RouteMatch_PathMatchPolicy with the uri_template_matcher extension,
  reusing the existing PathTemplateMatcher() from the authz matcher
  package for sanitization ({*}->*, {**}->**)
- Validation: pathTemplate is validated via CheckValidPathTemplate()
  (same as AuthorizationPolicy) and is restricted to uri matches only
- Delegate conflict detection: pathTemplate is treated as incompatible
  with delegate VirtualService composition
- Gateway API: getURIRank/getURILength updated to handle pathTemplate

Depends on istio/api#3675

Fixes istio#59533

Signed-off-by: Antonio <antoniomorales9711@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ok-to-test size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support {*} / {**} path template operators in VirtualService URI matching

3 participants