Error 500 when I am trying to list the services (/services) with an integer type on the offset param.
$ http GET :8001/services?offset=2
Kong version: 0.13.x
Log message:
2018/04/05 15:00:08 [error] 112#0: *153753 lua coroutine: runtime error: /usr/local/share/lua/5.1/kong/api/endpoints.lua:52: offset must be a string
stack traceback:
coroutine 0:
[C]: in function 'error'
/usr/local/share/lua/5.1/kong/db/dao/init.lua:214: in function 'page'
/usr/local/share/lua/5.1/kong/api/endpoints.lua:52: in function </usr/local/share/lua/5.1/kong/api/endpoints.lua:51>
coroutine 1:
[C]: in function 'resume'
/usr/local/share/lua/5.1/lapis/application.lua:393: in function 'handler'
/usr/local/share/lua/5.1/lapis/application.lua:130: in function 'resolve'
/usr/local/share/lua/5.1/lapis/application.lua:161: in function </usr/local/share/lua/5.1/lapis/application.lua:159>
[C]: in function 'xpcall'
/usr/local/share/lua/5.1/lapis/application.lua:159: in function 'dispatch'
/usr/local/share/lua/5.1/lapis/nginx.lua:215: in function 'serve_admin_api'
content_by_lua(nginx-kong.conf:148):2: in function <content_by_lua(nginx-kong.conf:148):1>, client: 192.168.65.3, server: kong_admin, request: "GET /services?offset=2 HTTP/1.1", host: "localhost:8001"
2018/04/05 15:00:08 [error] 112#0: *153753 [lua] init.lua:133: handle_error(): /usr/local/share/lua/5.1/lapis/application.lua:397: /usr/local/share/lua/5.1/kong/api/endpoints.lua:52: offset must be a string
stack traceback:
[C]: in function 'error'
/usr/local/share/lua/5.1/kong/db/dao/init.lua:214: in function 'page'
/usr/local/share/lua/5.1/kong/api/endpoints.lua:52: in function </usr/local/share/lua/5.1/kong/api/endpoints.lua:51>
stack traceback:
[C]: in function 'error'
/usr/local/share/lua/5.1/lapis/application.lua:397: in function 'handler'
/usr/local/share/lua/5.1/lapis/application.lua:130: in function 'resolve'
/usr/local/share/lua/5.1/lapis/application.lua:161: in function </usr/local/share/lua/5.1/lapis/application.lua:159>
[C]: in function 'xpcall'
/usr/local/share/lua/5.1/lapis/application.lua:159: in function 'dispatch'
/usr/local/share/lua/5.1/lapis/nginx.lua:215: in function 'serve_admin_api'
content_by_lua(nginx-kong.conf:148):2: in function <content_by_lua(nginx-kong.conf:148):1>, client: 192.168.65.3, server: kong_admin, request: "GET /services?offset=2 HTTP/1.1", host: "localhost:8001"
192.168.65.3 - - [05/Apr/2018:15:00:08 +0000] "GET /services?offset=2 HTTP/1.1" 500 54 "-" "HTTPie/0.9.9"
Offset is meant to be a Kong service uuid not numeric:
"next": "http://localhost:8001/services?offset=6378122c-a0a1-438d-a5c6-efabae9fb969"
You can do size = 1000 if you expect to never have more than 1k entries and not worry about pagination:
http://localhost:8001/services?size=1000
Hi @jeremyjpj0916
I am aware of it. I created the issue because the status 500 represents something went wrong in the application/server, and not on the client side (the request).
If you try to search for some invalid uuid, you gonna see the specification of the problem with the properly status.
There are a couple of issues created with similar problems.
Ah I see your point then, thought you were just unintentionally mixing up offset/size :) . Should be returning a HTTP 400 for a bad request in this case then 馃憤 .
Yes, we will add schema aware arguments parser at some point, to fix these wrongly (to number) type converted arguments. Until then we can consider it a bug. Fix is coming, it is just not yet on our table.
Fixed with #3416 (will be included in 0.14).
Most helpful comment
Soon: https://github.com/Kong/kong/tree/feat/admin-schema-aware-parser