Kong / kong

🦍 The Cloud-Native API Gateway and AI Gateway.
https://konghq.com/install/
Apache License 2.0
39.32k stars 4.82k forks source link

Error: bad argument #1 to 'ipairs' (table expected, got nil) #2491

Closed xulongju closed 6 years ago

xulongju commented 7 years ago

version: kong-0.10.2 openresty-1.11.2.2 Kong-0.10.1 upgrade to kong-0.10.2, the following error: Error: bad argument #1 to 'ipairs' (table expected, got nil)

Run with --v (verbose) or --vv (debug) for more details [root@localhost openresty]# kong start --vv 2017/05/03 20:00:57 [verbose] Kong: 0.10.2 2017/05/03 20:00:57 [debug] ngx_lua: 10007 2017/05/03 20:00:57 [debug] nginx: 1011002 2017/05/03 20:00:57 [debug] Lua: LuaJIT 2.1.0-beta2 2017/05/03 20:00:57 [verbose] no config file found at /etc/kong/kong.conf 2017/05/03 20:00:57 [verbose] no config file found at /etc/kong.conf 2017/05/03 20:00:57 [verbose] no config file, skipping loading Error: ...uite/openresty/luajit/share/lua/5.1/kong/conf_loader.lua:189: bad argument #1 to 'ipairs' (table expected, got nil) stack traceback: [C]: in function 'ipairs' ...uite/openresty/luajit/share/lua/5.1/kong/conf_loader.lua:189: in function 'check_and_infer' ...uite/openresty/luajit/share/lua/5.1/kong/conf_loader.lua:359: in function 'conf_loader' ...bsuite/openresty/luajit/share/lua/5.1/kong/cmd/start.lua:10: in function 'cmd_exec' ...ebsuite/openresty/luajit/share/lua/5.1/kong/cmd/init.lua:88: in function <...ebsuite/openresty/luajit/share/lua/5.1/kong/cmd/init.lua:88> [C]: in function 'xpcall' ...ebsuite/openresty/luajit/share/lua/5.1/kong/cmd/init.lua:88: in function <...ebsuite/openresty/luajit/share/lua/5.1/kong/cmd/init.lua:45> /opt/websuite/openresty/bin/kong:5: in function 'file_gen' init_worker_by_lua:38: in function [C]: in function 'pcall' init_worker_by_lua:45: in function

xulongju commented 7 years ago

old version: kong-0.10.1 openresty-1.11.2.1 update version: kong-0.10.2 openresty-1.11.2.2

p0pr0ck5 commented 7 years ago

@xulongju what does the content of your kong.conf file look like?

xulongju commented 7 years ago

[root@localhost openresty]# cat kong.conf prefix = /opt/config/openresty/kong/ log_level = error custom_plugins = anonymous_reports = off proxy_listen = 0.0.0.0:80 proxy_listen_ssl = 0.0.0.0:443 admin_listen = 10.10.10.106:8001 admin_listen_ssl = 10.10.10.106:8444 mem_cache_size = 128m ssl = on ssl_cert = ssl_cert_key = admin_ssl = off admin_ssl_cert = admin_ssl_cert_key = upstream_keepalive = 60 server_tokens = on latency_tokens = on database = postgres pg_host = 10.10.10.123 pg_port = 5432 pg_user = kong pg_password = kong pg_database = kong pg_ssl = off pg_ssl_verify = off cluster_listen = 10.10.10.106:7946 cluster_listen_rpc = 127.0.0.1:7373 cluster_advertise = cluster_encrypt_key = cluster_keyring_file = cluster_ttl_on_failure = 3600 cluster_profile = wan dns_resolver = dns_hostsfile = /etc/hosts lua_ssl_trusted_certificate = lua_ssl_verify_depth = 1 lua_code_cache = on lua_package_path = lua_package_cpath = lua_socket_pool_size = 30

xulongju commented 7 years ago

I re-compile and install kong 0.10.2, use openresty -1.11.2.2, start any error, as follows: [root@localhost cron.hourly]# kong start --vv 2017/05/07 09:45:17 [verbose] Kong: 0.10.2 2017/05/07 09:45:17 [debug] ngx_lua: 10006 2017/05/07 09:45:17 [debug] nginx: 1011002 2017/05/07 09:45:17 [debug] Lua: LuaJIT 2.1.0-beta2 2017/05/07 09:45:17 [verbose] reading config file at /opt/config/openresty/kong.conf Error: ...uite/openresty/luajit/share/lua/5.1/kong/conf_loader.lua:188: bad argument #1 to 'ipairs' (table expected, got nil) stack traceback: [C]: in function 'ipairs' ...uite/openresty/luajit/share/lua/5.1/kong/conf_loader.lua:188: in function 'check_and_infer' ...uite/openresty/luajit/share/lua/5.1/kong/conf_loader.lua:358: in function 'conf_loader' ...bsuite/openresty/luajit/share/lua/5.1/kong/cmd/start.lua:10: in function 'cmd_exec' ...ebsuite/openresty/luajit/share/lua/5.1/kong/cmd/init.lua:88: in function <...ebsuite/openresty/luajit/share/lua/5.1/kong/cmd/init.lua:88> [C]: in function 'xpcall' ...ebsuite/openresty/luajit/share/lua/5.1/kong/cmd/init.lua:88: in function <...ebsuite/openresty/luajit/share/lua/5.1/kong/cmd/init.lua:45> /opt/websuite/openresty/bin/kong:5: in function 'file_gen' init_worker_by_lua:38: in function [C]: in function 'pcall' init_worker_by_lua:45: in function

saga1015 commented 7 years ago

@p0pr0ck5 if kong.conf or kong_default.lua include "cassandra_contact_points" ,then run "kong migrations up" is OK if kong.conf or kong_default.lua is not include "cassandra_contact_points" ,then run "kong migrations up" is not work ,and print "Error: ...uite/openresty/luajit/share/lua/5.1/kong/conf_loader.lua:188: bad argument #1 to 'ipairs' (table expected, got nil)"

ivanpondal commented 7 years ago

Hello, I'm currently running into the same issue with Kong 0.10.1. I've got Cassandra client-node encryption working (was able to connect with cqlsh through ssl) but when I try to run kong with ssl verification disabled I receive the same error @xulongju reported. If I run the migrations manually I get the same result.

kevinpgrant commented 7 years ago

Same thing here on Kong 0.10.3 - see this in the error logs a lot although the request is a GET so there should not be a body to decode [lua] public.lua:27: get_body_args(): could not decode JSON body args: bad argument #1 to '?' (string expected, got nil), client: n.n.n.n, server: kong, request: "GET /some/path HTTP/1.1", host: "example.com"

thibaultcha commented 6 years ago

if kong.conf or kong_default.lua is not include "cassandra_contact_points"

Why would you remove this property from kong_default.lua? Why would you modify this file at all, even? Please don't.

@ivanpondal If you are still experiencing this on a more recent version of Kong, please open another issue with a reproducible use-case and the actual error you are seeing.

@kevinpgrant That is a completely different issue as per the error log - this does not even happen in the CLI. Anyway, it should be fixed in more recent versions (as of today, 0.13.1).