You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/06/23 17:13:48 UTC

[GitHub] [apisix] tzssangglass edited a comment on issue #4460: bug: The request-id plugin may have a bug

tzssangglass edited a comment on issue #4460:
URL: https://github.com/apache/apisix/issues/4460#issuecomment-867015652


   @zuiyangqingzhou  hi, I repeated your steps, cc @tokers
   
   step 1: set `request-id` on route
   
   ```shell
   curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
   {
       "uri":"/get",
       "plugins": {
           "request-id": {
               "header_name":"X-Request-Route-Id",
               "include_in_response": true
           }
       },
       "upstream":{
           "nodes":{
               "httpbin.org:80":1
           },
           "type":"roundrobin"
       }
   }'
   ```
   
   step 2: set `request-id` on global_rule
   
   ```shell
   curl http://127.0.0.1:9080/apisix/admin/global_rules/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
   {
       "plugins": {
           "request-id": {
               "header_name":"X-My-Request-id",
               "include_in_response": true
           }
       }
   }'
   ```
   
   step 3: send request
   
   ```shell
   curl -i 127.0.0.1:9080/get
   HTTP/1.1 200 OK
   Content-Type: application/json
   Content-Length: 429
   Connection: keep-alive
   Date: Wed, 23 Jun 2021 17:00:57 GMT
   Access-Control-Allow-Origin: *
   Access-Control-Allow-Credentials: true
   Server: APISIX/2.6
   X-My-Request-id: 2a3c2d84-7e8f-4dcd-8d85-d175f0bb9d7a
   X-Request-Route-Id: 2a3c2d84-7e8f-4dcd-8d85-d175f0bb9d7a
   
   {
     "args": {}, 
     "headers": {
       "Accept": "*/*", 
       "Host": "127.0.0.1", 
       "User-Agent": "curl/7.71.1", 
       "X-Amzn-Trace-Id": "Root=1-60d368c9-7ef6036b6b2944281ae48465", 
       "X-Forwarded-Host": "127.0.0.1", 
       "X-My-Request-Id": "8509eca0-be8c-4e1f-9186-8427569adfd1", 
       "X-Request-Route-Id": "2a3c2d84-7e8f-4dcd-8d85-d175f0bb9d7a"
     }, 
     "origin": "127.0.0.1, 58.152.81.86", 
     "url": "http://127.0.0.1/get"
   }
   ```
   
   I get the same error.
   
   by adding the log I found that the `ctx.x_request_id` https://github.com/apache/apisix/blob/2707fda3eb7b23d995ac23ecf4a17000dd765855/apisix/plugins/request-id.lua#L63-L64 is store the value generated by the request-id on the route, this is because the `request-id` on `route` is executed later than the one on `global_rule`.
   
   I think it should be explicitly stated that `request-id` plugin should not be configured on both `global_rule` and `route`, it doesn't make much sense.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org