Kong: Empty uris or host results in object {} instead of array [] in postgres database

Created on 31 Mar 2017  路  8Comments  路  Source: Kong/kong

Summary

Empty uris or host results in object {} instead of array [] in postgres database

Steps To Reproduce

  1. curl -i -X POST --url http://localhost:8001/apis/ --data 'name=example-api1' --data 'hosts=example.com1' --data 'upstream_url=http://httpbin.org' --data 'uris='
{
  "http_if_terminated":true,
  "id":"76a3b1d7-1c02-4f0b-91e0-3875ed23eca3",
  "retries":5,
  "preserve_host":false,
  "created_at":1490926514000,
  "upstream_connect_timeout":60000,
  "upstream_url":"http:\/\/httpbin.org",
  "upstream_read_timeout":60000,
  "upstream_send_timeout":60000,
  "https_only":false,
  "strip_uri":true,
  "uris":{},
  "name":"example-api1",
  "hosts":["example.com1"]
}

Additional Details & Logs

  • Kong version 0.10.0
  • Operating System
tasbug

Most helpful comment

We could fix this one now!

All 8 comments

One other note. I originally was using JSON in a patch request to change from having a uri to an empty list of uris.

Ah thanks for the report. While inelegant, this should eventually not be an issue for Kong. Since Lua makes no distinction between lists and hash tables, those will be inferred to empty Lua tables (empty lists) when retrieved by Kong.

Eventually, using cjson.empty_table will fix this, but we are currently waiting for an OpenResty release to be able to use those in Kong, due to a bug fix.

Thanks for the update.

I found it as I was passing the JSON to a javascript application and it was expecting an array. So it displayed [object] instead of the list of values. For now I updated my code to convert {} to [].

We'll take care of it when upgrading to the new OpenResty 1.11.2.3

We could fix this one now!

Is this fixed now? I see know my using 1.11.2.4 now?

@mynameisgv This hasn't been addressed, but considering the harmless nature of the bug, and our recent (unreleased) work on improving our DAO, it is unlikely that we will address it.

Given that a). API are not longer a thing, and b). the new DAO codebase takes care of this, I'm going to close this stale, legacy issue :)

Was this page helpful?
0 / 5 - 0 ratings