zheng11581 opened a new issue #1684:
URL: https://github.com/apache/incubator-apisix/issues/1684


   ### Issue description
   1. curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
   {
       "uris": ["/api/*"],
       "methods": ["GET", "POST"],
       "filter_func": "function(vars) 
           local body = vars[\"request_body\"]
           local a1 = body[\"a1\"]
           local a2 = body[\"a2\"]
           return a1 == \"a1\" and a2 == \"a2\"
       end",
       "upstream": {
           "type": "roundrobin",
           "nodes": {
               "127.0.0.1:20608": 1
           }
       }
   }'
   
   2. curl -i http://127.0.0.1:9080/api/index -X POST -d '{a1:"a1", a2:"a2"}'
   3. error.log
   2020/06/10 15:14:36 [error] 20343#20343: *34670661 lua entry thread aborted: 
runtime error: [string "router#1"]:3: attempt to index local 'body' (a nil 
value)
   stack traceback:
   coroutine 0:
        [string "router#1"]: in function 'filter_fun'
        /usr/local/apisix//deps/share/lua/5.1/resty/radixtree.lua:531: in 
function 'match_route_opts'
        /usr/local/apisix//deps/share/lua/5.1/resty/radixtree.lua:550: in 
function '_match_from_routes'
        /usr/local/apisix//deps/share/lua/5.1/resty/radixtree.lua:582: in 
function 'match_route'
        /usr/local/apisix//deps/share/lua/5.1/resty/radixtree.lua:614: in 
function 'dispatch'
        /usr/local/apisix/apisix/http/router/radixtree_uri.lua:110: in function 
'match'
        /usr/local/apisix/apisix/init.lua:285: in function 'http_access_phase'
        access_by_lua(nginx.conf:168):2: in main chunk, client: 127.0.0.1, 
server: , request: "POST /api/index HTTP/1.1", host: "127.0.0.1:9080"
   
   ### Environment
   
   * apisix version (cmd: `apisix version`): 1.3
   * OS: Centos 7
   


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


Reply via email to