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 2022/01/10 11:03:00 UTC
[GitHub] [apisix] shelltea opened a new issue #6066: bug: request-id plugin overwrite X-Request-Id already present in the request
shelltea opened a new issue #6066:
URL: https://github.com/apache/apisix/issues/6066
### Issue description
If `X-Request-Id` is already present in the request,the response didn't return the same value。
![image](https://user-images.githubusercontent.com/864375/148755044-6d641557-9a5d-4c6b-ad17-ae569978d487.png)
### Environment
- apisix version (cmd: `apisix version`): 2.10.2
- OS (cmd: `uname -a`): Linux apisix-85d66cc8b8-s7lb5 4.15.0-136-generic #140-Ubuntu SMP Thu Jan 28 05:20:47 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
- OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`):nginx version: openresty/1.19.3.2
built by gcc 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC)
built with OpenSSL 1.1.1l 24 Aug 2021
TLS SNI support enabled
configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt='-O2 -DAPISIX_BASE_VER=1.19.3.2.2 -DNGX_LUA_ABORT_AT_PANIC -I/usr/local/openresty/zlib/include -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl111/include' --add-module=../ngx_devel_kit-0.3.1 --add-module=../echo-nginx-module-0.62 --add-module=../xss-nginx-module-0.06 --add-module=../ngx_coolkit-0.2 --add-module=../set-misc-nginx-module-0.32 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.08 --add-module=../srcache-nginx-module-0.32 --add-module=../ngx_lua-0.10.19 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.33 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.19 --add-module=../redis2-nginx-module-0.15 --add-module=../redis-nginx-module-0.3.7 --add-module=../ngx_stream_lua-0.0.9 --with-ld-opt='-Wl,-rpath,/usr/local/openresty/luajit/lib -Wl,-rpath,/usr/local/openresty/wasmtime-c-api
/lib -L/usr/local/openresty/zlib/lib -L/usr/local/openresty/pcre/lib -L/usr/local/openresty/openssl111/lib -Wl,-rpath,/usr/local/openresty/zlib/lib:/usr/local/openresty/pcre/lib:/usr/local/openresty/openssl111/lib' --add-module=/tmp/tmp.wRcqhSzQQC/openresty-1.19.3.2/../mod_dubbo --add-module=/tmp/tmp.wRcqhSzQQC/openresty-1.19.3.2/../ngx_multi_upstream_module --add-module=/tmp/tmp.wRcqhSzQQC/openresty-1.19.3.2/../apisix-nginx-module --add-module=/tmp/tmp.wRcqhSzQQC/openresty-1.19.3.2/../wasm-nginx-module --add-module=/tmp/tmp.wRcqhSzQQC/openresty-1.19.3.2/../lua-var-nginx-module --with-poll_module --with-pcre-jit --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_v2_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_auth_request_module --with-http_secure_link_module --with-http_random_index_module --with-http_gzip_stati
c_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-threads --with-compat --with-stream --with-http_ssl_module
- etcd version, if have (cmd: run `curl http://127.0.0.1:9090/v1/server_info` to get the info from server-info API):
- apisix-dashboard version, if have:
- the plugin runner version, if the issue is about a plugin runner (cmd: depended on the kind of runner):
- luarocks version, if the issue is about installation (cmd: `luarocks --version`):
### Steps to reproduce
1. Enable request-id plugin.
2. Sent a request with `X-Request-Id`.
### Actual result
Response same value
### Error log
no error log
### Expected result
_No response_
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander closed issue #6066: bug: request-id plugin overwrite X-Request-Id already present in the request
Posted by GitBox <gi...@apache.org>.
spacewander closed issue #6066:
URL: https://github.com/apache/apisix/issues/6066
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] shelltea edited a comment on issue #6066: bug: request-id plugin overwrite X-Request-Id already present in the request
Posted by GitBox <gi...@apache.org>.
shelltea edited a comment on issue #6066:
URL: https://github.com/apache/apisix/issues/6066#issuecomment-1009555065
I think add an option might not solve my problem. Overwrite or not is dependent on the request-id exists in the header.If request-id is already exist in header,request-id plugin don't have to generate and reponse the request-id send by the client. If not exist,the request-id plugin should generate and response the generated value.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on issue #6066: bug: request-id plugin overwrite X-Request-Id already present in the request
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #6066:
URL: https://github.com/apache/apisix/issues/6066#issuecomment-1009548893
Maybe we can add options to control whether or not to override.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] shelltea commented on issue #6066: bug: request-id plugin overwrite X-Request-Id already present in the request
Posted by GitBox <gi...@apache.org>.
shelltea commented on issue #6066:
URL: https://github.com/apache/apisix/issues/6066#issuecomment-1008773944
I read the code:
https://github.com/apache/apisix/blob/master/apisix/plugins/request-id.lua#L212-L222
I think it should change to this:
```
function _M.rewrite(conf, ctx)
local uuid_val = core.request.header(ctx, conf.header_name)
if uuid_val == nil then
uuid_val = get_request_id(conf.algorithm)
core.request.set_header(ctx, conf.header_name, uuid_val)
end
if conf.include_in_response then
ctx["request-id-" .. conf.header_name] = uuid_val
end
end
```
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #6066: bug: request-id plugin overwrite X-Request-Id already present in the request
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #6066:
URL: https://github.com/apache/apisix/issues/6066#issuecomment-1009631753
We can add an option to disable the overwrite? If the option is true and the client sends the header, request-id will skip it.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on issue #6066: bug: request-id plugin overwrite X-Request-Id already present in the request
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #6066:
URL: https://github.com/apache/apisix/issues/6066#issuecomment-1009666772
> From the source code above, request-id plugin generated a request-id whether or not the request contains one.I think if a request has a request-id means request-id plugin don't have to generate one and response the same request-id sent by the client.If request don't have a request-id means request-id plugin need to generate and response the request-id generated by itself.So it not dependent on an option.
We can make this behavior as an option.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] shelltea commented on issue #6066: bug: request-id plugin overwrite X-Request-Id already present in the request
Posted by GitBox <gi...@apache.org>.
shelltea commented on issue #6066:
URL: https://github.com/apache/apisix/issues/6066#issuecomment-1009555065
I think add an option might not solve my problem. Overwrite or not is dependent on the request-id exists in the header.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] shelltea commented on issue #6066: bug: request-id plugin overwrite X-Request-Id already present in the request
Posted by GitBox <gi...@apache.org>.
shelltea commented on issue #6066:
URL: https://github.com/apache/apisix/issues/6066#issuecomment-1009627352
> I have a question, why do you need the request-id plugin when your request has a request-id?
Not all client's request has a request-id,Old version iOS or Android client don't have one.But i want all request proxy by APISIX has a request-id.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #6066: bug: request-id plugin overwrite X-Request-Id already present in the request
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #6066:
URL: https://github.com/apache/apisix/issues/6066#issuecomment-1009529774
You can change the default header of request-id.
https://github.com/apache/apisix/blob/master/docs/en/latest/plugins/request-id.md#attributes
It is strange to have two different sources for one header.
I think the overwrite behavior is expected.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #6066: bug: request-id plugin overwrite X-Request-Id already present in the request
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #6066:
URL: https://github.com/apache/apisix/issues/6066#issuecomment-1017310652
@shelltea
Sorry, now I confirm it is a bug after discussed with teammate.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander edited a comment on issue #6066: bug: request-id plugin overwrite X-Request-Id already present in the request
Posted by GitBox <gi...@apache.org>.
spacewander edited a comment on issue #6066:
URL: https://github.com/apache/apisix/issues/6066#issuecomment-1009529774
You can change the default header of request-id if you want to preserve the header from the client.
https://github.com/apache/apisix/blob/master/docs/en/latest/plugins/request-id.md#attributes
It is strange to have two different sources for one header.
I think the overwrite behavior is expected.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on issue #6066: bug: request-id plugin overwrite X-Request-Id already present in the request
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #6066:
URL: https://github.com/apache/apisix/issues/6066#issuecomment-1009611850
I have a question, why do you need the request-id plugin when your request has a request-id?
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on issue #6066: bug: request-id plugin overwrite X-Request-Id already present in the request
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #6066:
URL: https://github.com/apache/apisix/issues/6066#issuecomment-1008817154
Give the complete reproduction of the use case.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] shelltea commented on issue #6066: bug: request-id plugin overwrite X-Request-Id already present in the request
Posted by GitBox <gi...@apache.org>.
shelltea commented on issue #6066:
URL: https://github.com/apache/apisix/issues/6066#issuecomment-1009545805
Yes, Our request-id is generated by the client(iOS/Android), And already used the header name `X-Request-Id`. If i change the default header name, There's two request-id in header with no correlation. Our traceing system use `X-Request-Id` as TraceID, I can't relate the two values when i trouble-shooting, And also i want response the request-id send by the client.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] shelltea commented on issue #6066: bug: request-id plugin overwrite X-Request-Id already present in the request
Posted by GitBox <gi...@apache.org>.
shelltea commented on issue #6066:
URL: https://github.com/apache/apisix/issues/6066#issuecomment-1009638712
```
function _M.rewrite(conf, ctx)
local headers = ngx.req.get_headers()
local uuid_val = get_request_id(conf.algorithm)
if not headers[conf.header_name] then
core.request.set_header(ctx, conf.header_name, uuid_val)
end
if conf.include_in_response then
ctx["request-id-" .. conf.header_name] = uuid_val
end
end
```
From the source code above, request-id plugin generated a request-id whether or not the request contains one.I think if a request has a request-id means request-id plugin don't have to generate one and response the same request-id sent by the client.If request don't have a request-id means request-id plugin need to generate and response the request-id generated by itself.So it not dependent on an option.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] shelltea commented on issue #6066: bug: request-id plugin overwrite X-Request-Id already present in the request
Posted by GitBox <gi...@apache.org>.
shelltea commented on issue #6066:
URL: https://github.com/apache/apisix/issues/6066#issuecomment-1009678530
OK,If the whole behavior as an option,I think this is a feasible solution. Thanks! @tzssangglass @spacewander
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org