Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
pauldaustin opened this issue Mar 31, 2017 · 8 comments
Assignees
Labels

Comments

@pauldaustin
Copy link

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
@pauldaustin
Copy link
Author

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

@thibaultcha
Copy link
Member

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.

@pauldaustin
Copy link
Author

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 [].

@thibaultcha
Copy link
Member

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

@hbagdi
Copy link
Member

hbagdi commented Nov 18, 2017

We could fix this one now!

@mynameisgv
Copy link
Contributor

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

@thibaultcha
Copy link
Member

@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.

@p0pr0ck5
Copy link
Contributor

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants