Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate_request_id does not generate x-request-id if it is present but empty #38445

Open
quantumsheep opened this issue Feb 13, 2025 · 2 comments · May be fixed by #38474
Open

generate_request_id does not generate x-request-id if it is present but empty #38445

quantumsheep opened this issue Feb 13, 2025 · 2 comments · May be fixed by #38474
Labels
area/tracing help wanted Needs help! question Questions that are neither investigations, bugs, nor enhancements

Comments

@quantumsheep
Copy link
Contributor

Title: generate_request_id does not generate x-request-id if it is present but empty

Description

I expected generate_request_id to generate a x-request-id if it isn't present OR empty. But this seems to not be the case. Is this intended? If so, do you have a solution to generate it if it's empty?

Repro steps

The config (found bellow) is run with the following command:

docker run --rm -v $(pwd)/envoy.yaml:/etc/envoy/envoy.yaml -p 80:80 envoyproxy/envoy:v1.31-latest

Without passing x-request-id

In this case, the x-request-id header is generated.

# x-request-id present in response
curl http://localhost:80/ -v

Output:

* Host localhost:80 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:80...
* Connected to localhost (::1) port 80
> GET / HTTP/1.1
> Host: localhost
> User-Agent: curl/8.7.1
> Accept: */*
>
* Request completely sent off
< HTTP/1.1 200 OK
< content-length: 2
< content-type: text/plain
< date: Thu, 13 Feb 2025 10:34:01 GMT
< server: envoy
< x-request-id: e4dcd48e-9914-416d-a60e-fa57e119c1a8
<
* Connection #0 to host localhost left intact
OK

Explicitly passing x-request-id

In this case, the x-request-id header is forwarded in the response because of always_set_request_id_in_response: true.

curl -H"x-request-id: hello" http://localhost:80/ -v

Output:

* Host localhost:80 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:80...
* Connected to localhost (::1) port 80
> GET / HTTP/1.1
> Host: localhost
> User-Agent: curl/8.7.1
> Accept: */*
> x-request-id: hello
>
* Request completely sent off
< HTTP/1.1 200 OK
< content-length: 2
< content-type: text/plain
< date: Thu, 13 Feb 2025 10:37:13 GMT
< server: envoy
< x-request-id: hello
<
* Connection #0 to host localhost left intact
OK

Explicitly passing an empty x-request-id

In this case, the x-request-id header is forwarded in the response because of always_set_request_id_in_response: true. But generate_request_id: true should have generated one.

curl -H"x-request-id;" http://localhost:80/ -v

Output:

* Host localhost:80 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:80...
* Connected to localhost (::1) port 80
> GET / HTTP/1.1
> Host: localhost
> User-Agent: curl/8.7.1
> Accept: */*
> x-request-id:
>
* Request completely sent off
< HTTP/1.1 200 OK
< content-length: 2
< content-type: text/plain
< date: Thu, 13 Feb 2025 10:38:18 GMT
< server: envoy
< x-request-id:
<
* Connection #0 to host localhost left intact
OK

Config

admin:
  address:
    socket_address: { address: 0.0.0.0, port_value: 9901 }

static_resources:
  listeners:
    - name: listener_0
      address:
        socket_address: { address: 0.0.0.0, port_value: 80 }
      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
                generate_request_id: true
                always_set_request_id_in_response: true
                route_config:
                  virtual_hosts:
                    - name: local_service
                      domains: ["*"]
                      routes:
                        - match: { prefix: "/" }
                          direct_response:
                            status: 200
                            body:
                              inline_string: "OK"
                http_filters:
                  - name: envoy.filters.http.router
                    typed_config:
                      "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
@quantumsheep quantumsheep added bug triage Issue requires triage labels Feb 13, 2025
@mattklein123 mattklein123 added question Questions that are neither investigations, bugs, nor enhancements area/tracing and removed bug triage Issue requires triage labels Feb 14, 2025
@mattklein123
Copy link
Member

cc @wbpcode

@wbpcode
Copy link
Member

wbpcode commented Feb 16, 2025

Sounds reasonable for me to treat empty request id as not exist and create a new one.

@wbpcode wbpcode added the help wanted Needs help! label Feb 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/tracing help wanted Needs help! question Questions that are neither investigations, bugs, nor enhancements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants