Skip to content
This repository has been archived by the owner on Nov 17, 2020. It is now read-only.

Wrong JSON data type for empty publish-properties in /api/parameters/shovel #75

Closed
smee opened this issue Oct 21, 2015 · 6 comments
Closed

Comments

@smee
Copy link

smee commented Oct 21, 2015

If I create a dynamic shovel via pushing to /api/parameters/shovel with a publish-properties attribute like this

 curl -i -u guest:guest -H "content-type:application/json" -XPUT \
-d'{"value":{"dest-exchange":"amq.direct","src-queue":"test","dest-uri":"amqp://", "src-uri":"amqp://","publish-properties":{"user_id":"guest"}}}' \
http://localhost:15672/api/parameters/shovel/%2f/test1

I can see at /api/parameters/shovel/%2f/test1 that the attribute publish-properties is a JSON object. If I instead create a queue with an empty publish-properties like

 curl -i -u guest:guest -H "content-type:application/json" -XPUT \
-d'{"value":{"dest-exchange":"amq.direct","src-queue":"test","dest-uri":"amqp://", "src-uri":"amqp://","publish-properties":{}}}' \
http://localhost:15672/api/parameters/shovel/%2f/test1

the data type of this field is a JSON array instead. Is it possible to either not show the property or use an empty object?

@michaelklishin
Copy link
Member

This was fixed in several places before,
returning an empty array is possible.

On 21 oct 2015, at 12:40, Steffen Dienst notifications@github.com wrote:

If I create a dynamic shovel via pushing to /api/parameters/shovel with a publish-properties attribute like this

curl -i -u guest:guest -H "content-type:application/json" -XPUT
-d'{"value":{"dest-exchange":"amq.direct","src-queue":"test","dest-uri":"amqp://", "src-uri":"amqp://","publish-properties":{"user_id":"guest"}}}'
http://localhost:15672/api/parameters/shovel/%2f/test1
I can see at /api/parameters/shovel/%2f/test1 that the attribute publish-properties is a JSON object. If I instead create a queue with an empty publish-properties like

curl -i -u guest:guest -H "content-type:application/json" -XPUT
-d'{"value":{"dest-exchange":"amq.direct","src-queue":"test","dest-uri":"amqp://", "src-uri":"amqp://","publish-properties":{}}}'
http://localhost:15672/api/parameters/shovel/%2f/test1
the data type of this field is a JSON array instead. Is it possible to either not show the property or use an empty object?


Reply to this email directly or view it on GitHub.

@smee
Copy link
Author

smee commented Oct 21, 2015

You mean only an empty array? Not an empty object?

@michaelklishin
Copy link
Member

An empty object, sorry. The issue here is that proplists are lists in Erlang and so empty proplists are serialised as empty lists unless mochijson2 is instructed otherwise.

On 21 oct 2015, at 12:49, Steffen Dienst notifications@github.com wrote:

You mean only an empty array? Not an empty object?


Reply to this email directly or view it on GitHub.

@michaelklishin michaelklishin added this to the 3.6.1 milestone Jan 12, 2016
@michaelklishin
Copy link
Member

This belongs to shovel-management but lets keep it here.

@michaelklishin
Copy link
Member

We've evaluated this and there is an issue with Erlang JSON libraries prior to 17.x: they use lists to express what is objects in JSON. So we can't reliably tell an empty list from an empty object. In master we will switch to maps. For 3.6.x, we will look at what we can do.

@essen
Copy link
Contributor

essen commented Mar 11, 2016

Just sent two PRs with a proposal for a fix for this on stable. It's dirty really, and I have not run the full test suites to make sure I didn't break anything. Looking to see if that sort of fix is OK.

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

No branches or pull requests

3 participants