Skip to content

bug: The request-id plugin may have a bug #4460

Description

@zuiyangqingzhou

Issue description

When I enable the global request-id plugin and the request-id plugin on the route at the same time, there will be a BUG

Bug report without environment information will be ignored or closed.

  • apisix version (cmd: apisix version): 2.6
  • OS (cmd: uname -a): Darwin Kernel Version 20.5.0
  • OpenResty / Nginx version (cmd: nginx -V or openresty -V): nginx version: openresty/1.19.3.2
  • etcd version, if have (cmd: run curl http://127.0.0.1:9090/v1/server_info to get the info from server-info API): etcd Version: 3.4.16
  • apisix-dashboard version, if have:
  • luarocks version, if the issue is about installation (cmd: luarocks --version):

Minimal test code / Steps to reproduce the issue

Bug report without steps to reproduce will be ignored or closed.

  1. I enable the request-id plugin on a specific route, the default header_name is X-Request-Id, and I get the following result, which looks normal
$ curl -i http://127.0.0.1:9080/hello -H 'Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJrZXkiOiJ0ZXN0LWp3dC1kZW1vLTEiLCJleHAiOjE2MjQzNTk3MjZ9.TF2o2KngjIHMYO2CqPurPr1f2UnZVry76kN2XOyKEIU'

HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 408
Connection: keep-alive
Date: Tue, 22 Jun 2021 02:25:37 GMT
Server: APISIX/2.6
X-Request-Id: f02ac2c2-5333-4c03-a4ba-9b81fafdcdab

# my upstream get headers from apisix
Header全部数据: map[Accept:[*/*] Authorization:[eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJrZXkiOiJ0ZXN0LWp3dC1kZW1vLTEiLCJleHAiOjE2MjQzNTk3MjZ9.TF2o2KngjIHMYO2CqPurPr1f2UnZVry76kN2XOyKEIU] User-Agent:[curl/7.64.1] X-Forwarded-For:[127.0.0.1] X-Forwarded-Host:[127.0.0.1] X-Forwarded-Port:[9080] X-Forwarded-Proto:[http] X-Real-Ip:[127.0.0.1] X-Request-Id:[f02ac2c2-5333-4c03-a4ba-9b81fafdcdab]]
  1. I enable a global request-id plug-in, header_name is X-My-Request-id, request again, it seems that there is a problem

Environment

$ curl -i http://127.0.0.1:9080/hello -H 'Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJrZXkiOiJ0ZXN0LWp3dC1kZW1vLTEiLCJleHAiOjE2MjQzNTk3MjZ9.TF2o2KngjIHMYO2CqPurPr1f2UnZVry76kN2XOyKEIU'

HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 463
Connection: keep-alive
Date: Tue, 22 Jun 2021 02:28:22 GMT
Server: APISIX/2.6
X-My-Request-Id: 0c547cd1-8789-4369-9bca-f185f3e20309
X-Request-Id: 0c547cd1-8789-4369-9bca-f185f3e20309

# my upstream get header from apisix
Header全部数据: map[Accept:[*/*] Authorization:[eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJrZXkiOiJ0ZXN0LWp3dC1kZW1vLTEiLCJleHAiOjE2MjQzNTk3MjZ9.TF2o2KngjIHMYO2CqPurPr1f2UnZVry76kN2XOyKEIU] User-Agent:[curl/7.64.1] X-Forwarded-For:[127.0.0.1] X-Forwarded-Host:[127.0.0.1] X-Forwarded-Port:[9080] X-Forwarded-Proto:[http] X-My-Request-Id:[cbe7a2c9-8667-4016-8298-9104b0829ab4] X-Real-Ip:[127.0.0.1] X-Request-Id:[0c547cd1-8789-4369-9bca-f185f3e20309]]

image

As you can see, the X-My-Request-Id in the header returned by the request is different from the X-My-Request-Id obtained by upstream.

What's the actual result? (including assertion message & call stack if applicable)

What's the expected result?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions