Skip to content

[docs]: Incorrect docs for present_match HeaderMatcher #17345

Closed

Description

@peterj

Title: Incorrect docs for present_match HeaderMatcher

Description:
The docs for present_match state the following:

If specified as false, header match will be performed based on whether the header is absent.

This is not the case, as setting the present_match to false doesn't check for the absence of the header, the behavior is exactly the same as when present_match is set to true

Relevant Links:
This is a related issue that describes the problem, however, the docs still state false would check for absence.

Activity

  1. added
    triage
    on Jul 14, 2021
  2. phlax commented on Jul 15, 2021

    @phlax
    Member

    @peterj i dont know so much about this specific issue but if you create a PR to fix the docs im happy to review and/or ping others that do

  3. added and removed
    triage
    on Jul 15, 2021
  4. self-assigned this
    on Jul 15, 2021
  5. peterj commented on Jul 15, 2021

    @peterj
    ContributorAuthor

    I found a newer issue/PR where this functionality was supposed to fix it (#14656), however, it's not clear if the behavior is by design (i.e. you must the combination of present_match=false and invert_match=true to check for an absence of the header).

    Using the config below (with present_match=false) the behavior I'd expect is the following:

    1. curl localhost:10000 - hello header is not present and I should get the HTTP 200 and Hello response back.
    2. curl -H "hello: 1" localhost:1000 - hello is header is present, I should get back a 404 (since we're looking for the absence of the header).

    The actual behavior is like this:

    1. curl localhost:10000 - I get back HTTP 404 which is by my logic wrong; I am looking for the absence of hello header, hence the request should go through
    2. curl -H "hello: 1" localhost:1000 - I get back the HTTP 200 response which is wrong again.

    Based on this, regardless of the present_match value, it always checks for the presence of the header.

    envoy-config.yaml
    static_resources:
      listeners:
      - name: listener_0
        address:
          socket_address:
            address: 0.0.0.0
            port_value: 10000
        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: envoy.filters.http.router
              route_config:
                name: local_route
                virtual_hosts:
                - name: local_service
                  domains: ["*"]
                  routes:
                  - match:
                      prefix: "/"
                      headers:
                      - name: hello
                        present_match: false
                    direct_response:
                      status: 200
                      body:
                        inline_string: "Hello"
    
  6. soulxu commented on Jul 16, 2021

    @soulxu
    Member

    @peterj #14656 was fixed by #16627

    I tested your config, I can get HTTP status code 200 with request 'curl localhost:10000'. Also, I can get 404 with 'curl localhost:10000 -H 'hello: world'

    Which version you are testing? The fixed is just merge in main, not release yet. so it works with main branch.

  7. peterj commented on Jul 19, 2021

    @peterj
    ContributorAuthor

    ah, you're completely right. I was using the released versions (1.18.x and 1.19).

  8. github-actions commented on Aug 19, 2021

    @github-actions

    This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

  9. added
    stale
    on Aug 19, 2021
  10. github-actions commented on Aug 26, 2021

    @github-actions

    This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.

  11. hanjm commented on Jul 7, 2022

    @hanjm

    still valid

  12. soulxu commented on Jul 7, 2022

    @soulxu
    Member

    @hanjm I tested this on the main branch, it works as expected. Would you like show your envoy config? and which version you are running on?

    I tested with config:

              route_config:
                name: local_route
                virtual_hosts:
                - name: local_service
                  domains: ["*"]
                  routes:
                  - match:
                      path: /
                      headers:
                      - name: TEST
                        present_match: false
                    route:
                      cluster: my_cluster
    

    Then without header, it will match:

    curl -v http://127.0.0.1:33333
    *   Trying 127.0.0.1:33333...
    * TCP_NODELAY set
    * Connected to 127.0.0.1 (127.0.0.1) port 33333 (#0)
    > GET / HTTP/1.1
    > Host: 127.0.0.1:33333
    > User-Agent: curl/7.68.0
    > Accept: */*
    >
    * Mark bundle as not supporting multiuse
    < HTTP/1.1 200 OK
    < Date: Wed, 15 Jun 2022 07:26:57 GMT
    < Content-Length: 0
    <
    * Connection #0 to host 127.0.0.1 left intact
    * 
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/docsarea/httparea/matchingstale

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions