Kong-1.4.0 config db_export error

Hi, I get an error when I run ‘kong config db_export kong-1.4.0.yml’ on the 1.4.0.


/usr/local/share/lua/5.1/kong/db/declarative/init.lua:276: bad argument #1 to 'write' (string expected, got nil)
stack traceback:
        [C]: in function 'write'
        /usr/local/share/lua/5.1/kong/db/declarative/init.lua:276: in function 'export_from_db'
        /usr/local/share/lua/5.1/kong/cmd/config.lua:41: in function 'cmd_exec'
        /usr/local/share/lua/5.1/kong/cmd/init.lua:87: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:87>
        [C]: in function 'xpcall'
        /usr/local/share/lua/5.1/kong/cmd/init.lua:87: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:44>
        /usr/local/bin/kong:9: in function 'file_gen'
        init_worker_by_lua:49: in function <init_worker_by_lua:47>
        [C]: in function 'xpcall'
        init_worker_by_lua:56: in function <init_worker_by_lua:54>

And that I checked the 276 line in that source file and added some code to output the error of the function declarative.to_yaml_string, and got:

/usr/local/share/lua/5.1/lyaml/init.lua:126: cannot dump object of type 'userdata'

The problem now points to the lyaml, but I don’t know much more about it. So I use cjson instead of it and get some hint:

A lots json data has been dumped, I just left some useful

{"keyauth_credentials":[{"ttl":null, "key":"KU8YtaeOqnxa7ZzmXikkikXij8Ez47m3"}]}

According to the json data that lyaml should not be able to handle "ttl":null, because null is cjson.null in the table of lua and cjson.null is the type of userdata.

I did not continue to trace the null where it from, just a simple search for the source code that it may be caused by tb["ttl"] = ngx.null. I think this is the problem.


  • the lyaml can’t handle the type of userdata in Lua