Issue description
Environment
- apisix version (cmd:
apisix version): 2.6
- OS (cmd:
uname -a): centos 7.8
Minimal test code / Steps to reproduce the issue
{
"uris": [
"/*"
],
"name": "route",
"methods": [
"GET"
],
"vars": [
[
"cookie_upstream",
"==",
"dev"
]
],
"status": 1
}
When cookie cookie_upstream not found.
2021/07/01 19:30:06 [warn] 46#46: *2782 [lua] ctx.lua:157: __index(): failed to fetch cookie value by key: cookie_upstream error: nil, client: 127.0.0.1, server: _, request: "GET / HTTP/1.1", host: "localhost:9181"
When cookie header not exists.
2021/07/01 19:38:50 [warn] 46#46: *19719 [lua] ctx.lua:157: __index(): failed to fetch cookie value by key: cookie_upstream error: no cookie found in the current request, client: 127.0.0.1, server: _, request: "GET / HTTP/1.1", host: "localhost:9181"
It generates a lot of useless logs. If this is unexpected, I can submit a pr.
elseif core_str.has_prefix(key, "cookie_") then
local cookie = t.cookie
- if cookie then
+ if cookie and ngx.var.http_cookie then
local err
val, err = cookie:get(sub_str(key, 8))
- if not val then
+ if err then
log.warn("failed to fetch cookie value by key: ",
key, " error: ", err)
end
Issue description
Environment
apisix version): 2.6uname -a): centos 7.8Minimal test code / Steps to reproduce the issue
When cookie cookie_upstream not found.
When cookie header not exists.
It generates a lot of useless logs. If this is unexpected, I can submit a pr.
elseif core_str.has_prefix(key, "cookie_") then local cookie = t.cookie - if cookie then + if cookie and ngx.var.http_cookie then local err val, err = cookie:get(sub_str(key, 8)) - if not val then + if err then log.warn("failed to fetch cookie value by key: ", key, " error: ", err) end