slene opened a new issue #4516:
URL: https://github.com/apache/apisix/issues/4516


   ### 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.
   
   ```diff
                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
   ```
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to