nanamikon commented on a change in pull request #4676:
URL: https://github.com/apache/apisix/pull/4676#discussion_r679808294



##########
File path: apisix/core/ctx.lua
##########
@@ -159,7 +159,18 @@ do
                     val, err = cookie:get(sub_str(key, 8))
                     if err then
                         log.warn("failed to fetch cookie value by key: ",
-                                 key, " error: ", err)
+                                key, " error: ", err)
+                    end
+                end
+
+            elseif core_str.has_prefix(key, "arg_") then
+                local arg_key = sub_str(key, 5)
+                local args = request.get_uri_args(ngx.ctx)[arg_key]

Review comment:
       I add ngx.ctx, because of the following exception
   ```
    Failed test 'TEST 7: support dash in the args(arg is missing) - pattern 
"[error]" should not match any line in error.log but matches line "2021/07/30 
18:02:36 [error] 17776\#574167: *10 lua entry thread aborted: runtime error: 
/Users/jianzhou/workspace/apisix/apisix/core/request.lua:132: attempt to index 
local 'ctx' (a nil value)" (req 0)
   # stack traceback:
   # coroutine 0:
   #       /Users/jianzhou/workspace/apisix/apisix/core/request.lua: in 
function 'get_uri_args'
   #       /Users/jianzhou/workspace/apisix/apisix/core/ctx.lua:168: in 
function '__index'
   #       content_by_lua(nginx.conf:179):6: in main chunk, client: 127.0.0.1, 
server: localhost, request: "GET /t HTTP/1.1", host: "localhost"
   
   ```
   Should I modify the test case ? 
   Refer to request.t
   
   ```
               local core = require("apisix.core")
               local ngx_ctx = ngx.ctx
               local api_ctx = ngx_ctx.api_ctx
               if api_ctx == nil then
                   api_ctx = core.tablepool.fetch("api_ctx", 0, 32)
                   ngx_ctx.api_ctx = api_ctx
               end
   
               core.ctx.set_vars_meta(api_ctx)
   ```




-- 
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