envoyproxy / envoy

Cloud-native high-performance edge/middle/service proxy
https://www.envoyproxy.io
Apache License 2.0
24.97k stars 4.81k forks source link

schema_validator_tool errors on valid envoy.extensions.common.matching.v3.ExtensionWithMatcher configuration #36808

Open phamann opened 1 week ago

phamann commented 1 week ago

Title: schema_validator_tool errors on valid envoy.extensions.common.matching.v3.ExtensionWithMatcher configuration

Description: The schema_validator_tool errors on a valid, reduced test case, configuration of the envoy.extensions.common.matching.v3.ExtensionWithMatcher, with an INVALID_ARGUMENT: could not find @type 'type.googleapis.com/envoy.extensions.common.matching.v3.ExtensionWithMatcher') error message.

Repro steps: Use the example configuration, taken directly from the public docs for Matching API: Match Tree Validation, and pass to the schema_validator_tool, such as schema_validator_tool --schema-type bootstrap --config-path test.yaml and the validator will return an error.

https://www.envoyproxy.io/docs/envoy/v1.32.0/intro/arch_overview/advanced/matching/matching_api#match-tree-validation

This configuration is valid and works when ran via envoy --mode serve or envoy --mode validate.

Config:

static_resources:
  listeners:
  - address:
      socket_address:
        address: 0.0.0.0
        port_value: 443
    listener_filters:
    filter_chains:
    - filters:
      - name: envoy.filters.network.http_connection_manager
        typed_config:
          "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
          stat_prefix: ingress_http
          http_filters:
          - name: with-matcher
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.common.matching.v3.ExtensionWithMatcher
              extension_config:
                name: envoy.filters.http.fault
                typed_config:
                  "@type": type.googleapis.com/envoy.extensions.filters.http.fault.v3.HTTPFault
                  abort:
                    http_status: 503
                    percentage:
                      numerator: 0
                      denominator: HUNDRED
                  delay:
                    fixed_delay: 3s
                    percentage:
                      numerator: 0
                      denominator: HUNDRED
              xds_matcher:
                matcher_list:
                  matchers:
                  - predicate:
                      or_matcher:
                        predicate:
                        - single_predicate:
                            input:
                              name: request-headers
                              typed_config:
                                "@type": type.googleapis.com/envoy.type.matcher.v3.HttpRequestHeaderMatchInput
                                header_name: request-header
                            value_match:
                              exact: foo
                        - single_predicate:
                            input:
                              name: request-headers
                              typed_config:
                                "@type": type.googleapis.com/envoy.type.matcher.v3.HttpResponseHeaderMatchInput
                                header_name: response-header
                            value_match:
                              exact: bar
                    on_match:
                      action:
                        name: skip
                        typed_config:
                          "@type": type.googleapis.com/envoy.extensions.filters.common.matcher.action.v3.SkipFilter
          - name: envoy.filters.http.router
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
          route_config:
            virtual_hosts:
            - name: default
              domains: ["*"]
              routes:
              - match: {prefix: "/"}
                route:
                  cluster: service_foo
  clusters:
  - name: service_foo
    load_assignment:
      cluster_name: some_service
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: 127.0.0.1
                port_value: 8080

Logs:

Unable to parse JSON as proto (INVALID_ARGUMENT: could not find @type 'type.googleapis.com/envoy.extensions.common.matching.v3.ExtensionWithMatcher'): {"static_resources":{"clusters":[{"load_assignment":{"cluster_name":"some_service","endpoints":[{"lb_endpoints":[{"en
dpoint":{"address":{"socket_address":{"port_value":8080,"address":"127.0.0.1"}}}}]}]},"name":"service_foo"}],"listeners":[{"address":{"socket_address":{"port_value":443,"address":"0.0.0.0"}},"listener_filters":null,"filter_chains":[{"filters":[{"name":"envoy.filters.n
etwork.http_connection_manager","typed_config":{"stat_prefix":"ingress_http","route_config":{"virtual_hosts":[{"routes":[{"route":{"cluster":"service_foo"},"match":{"prefix":"/"}}],"domains":["*"],"name":"default"}]},"http_filters":[{"name":"with-matcher","typed_confi
g":{"xds_matcher":{"matcher_list":{"matchers":[{"predicate":{"or_matcher":{"predicate":[{"single_predicate":{"input":{"typed_config":{"@type":"type.googleapis.com/envoy.type.matcher.v3.HttpRequestHeaderMatchInput","header_name":"request-header"},"name":"request-header
s"},"value_match":{"exact":"foo"}}},{"single_predicate":{"input":{"name":"request-headers","typed_config":{"header_name":"response-header","@type":"type.googleapis.com/envoy.type.matcher.v3.HttpResponseHeaderMatchInput"}},"value_match":{"exact":"bar"}}}]}},"on_match":
{"action":{"name":"skip","typed_config":{"@type":"type.googleapis.com/envoy.extensions.filters.common.matcher.action.v3.SkipFilter"}}}}]}},"@type":"type.googleapis.com/envoy.extensions.common.matching.v3.ExtensionWithMatcher","extension_config":{"name":"envoy.filters.
http.fault","typed_config":{"abort":{"percentage":{"numerator":0,"denominator":"HUNDRED"},"http_status":503},"delay":{"fixed_delay":"3s","percentage":{"numerator":0,"denominator":"HUNDRED"}},"@type":"type.googleapis.com/envoy.extensions.filters.http.fault.v3.HTTPFault
"}}}},{"typed_config":{"@type":"type.googleapis.com/envoy.extensions.filters.http.router.v3.Router"},"name":"envoy.filters.http.router"}],"@type":"type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager"}}]}]}]}}
nezdolik commented 5 days ago

cc @phlax @mattklein123