Kong / kong

🦍 The Cloud-Native API Gateway and AI Gateway.
https://konghq.com/install/#kong-community
Apache License 2.0
39.22k stars 4.81k forks source link

Request size limiting plugin error #306

Closed montanaflynn closed 9 years ago

montanaflynn commented 9 years ago

After adding the requestsizelimiting plugin to an API all subsequent calls return a 500 error.

From errors.log:

2015/06/06 00:00:49 [error] 477#0: *26126 [lua] responses.lua:52: send_HTTP_INTERNAL_SERVER_ERROR(): An unexpected error occurred, client: 127.0.0.1, server: _, request: "GET / HTTP/1.0", host: "127.0.0.1:8001"
2015/06/06 00:00:49 [error] 477#0: *26134 lua entry thread aborted: runtime error: ...hare/lua/5.1/kong/plugins/requestsizelimiting/access.lua:15: attempt to compare number with nil
stack traceback:
coroutine 0:
    ...hare/lua/5.1/kong/plugins/requestsizelimiting/access.lua: in function 'execute'
    ...are/lua/5.1/kong/plugins/requestsizelimiting/handler.lua:14: in function 'access'
    /usr/local/share/lua/5.1/kong.lua:206: in function 'exec_plugins_access'
    access_by_lua(nginx.conf:87):1: in function <access_by_lua(nginx.conf:87):1>, client: 127.0.0.1, server: _, request: "GET / HTTP/1.0", host: "127.0.0.1:8001"
2015/06/06 00:00:49 [error] 477#0: *26134 [lua] responses.lua:52: send_HTTP_INTERNAL_SERVER_ERROR(): An unexpected error occurred, client: 127.0.0.1, server: _, request: "GET / HTTP/1.0", host: "127.0.0.1:8001"

How to reproduce:

$ curl -X POST \
    --url http://localhost:8001/apis/ \
    --data 'name=benchmark' \
    --data 'target_url=http://127.0.0.1:8001/robots.txt' \
    --data 'public_dns=benchmark.api'

{"public_dns":"benchmark.api","target_url":"http:\/\/127.0.0.1:8001\/robots.txt","id":"50989ecf-6329-48ee-c843-a8d14b594112","created_at":1433549350000,"name":"benchmark"}

$ curl -i -X POST http://localhost:8001/apis/50989ecf-6329-48ee-c843-a8d14b594112/plugins \
    --data "name=requestsizelimiting"

HTTP/1.1 201 Created
Date: Sat, 06 Jun 2015 00:09:20 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Server: kong/0.3.0

{"api_id":"50989ecf-6329-48ee-c843-a8d14b594112","id":"3f9faf9a-3320-4dea-cde4-09e65013b3fa","value":{"allowed_payload_size":128},"enabled":true,"created_at":1433549360000,"name":"requestsizelimiting"}

$ curl -i localhost:8000 -H "host:benchmark.api"

HTTP/1.1 500 Internal Server Error
Date: Sat, 06 Jun 2015 00:09:44 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: close
Server: kong/0.3.0

{"message":"An unexpected error occurred"}
shashiranjan84 commented 9 years ago

yes, it failing for request not having content-length header. pushed the fix

subnetmarco commented 9 years ago

@shashiranjan84 closed?

shashiranjan84 commented 9 years ago

Yes On Jun 5, 2015 6:25 PM, "Marco Palladino" notifications@github.com wrote:

@shashiranjan84 https://github.com/shashiranjan84 closed?

— Reply to this email directly or view it on GitHub https://github.com/Mashape/kong/issues/306#issuecomment-109494849.