You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am having an issue with the query parameter values being duplicated when building a liberator resource using with-json-mixin. I'm not entirely sure if that's a bug or not, but hopefully we can get more details on this.
What happens is that when a get request is being made with a multi-value query string ie https://some.url?thing=1&thing=2 I would have expected the parsed params to be something like [1 2] but what I see instead is [1 2 1 2 1 2]. As you would expect, if there are any specs configured the request would not be valid.
To have a better understanding on what is happening I have the following tests:
As you can see from above the issue occurs when using with-json-mixin, but when leaving out with-json-encoder and with-json-decoder everything seems to be working as expected. It may seem as the issue is somehow related to those 2 mixings even though they're not doing a lot apart from adding a map to the context. Something strange seems to happen within the merge-actions function as this is the point where those params values are being duplicated
and more specifically within the liberator update-context which seems to concatenate the vectors within the params unless it's explicitly decorated with the replace metadata as mentioned here. The params are decorated with the replace metadata, but within with-params-parsed-as-json that's the last mixin to be added as part of with-json-mixin and by then the params values have already been duplicated.
As a workaround I've created an internal mixin that takes care of decorating the params with the replace metadata and placed it before with-json-mixin:
Hi,
I am having an issue with the query parameter values being duplicated when building a liberator resource using
with-json-mixin
. I'm not entirely sure if that's a bug or not, but hopefully we can get more details on this.What happens is that when a get request is being made with a multi-value query string ie
https://some.url?thing=1&thing=2
I would have expected the parsed params to be something like[1 2]
but what I see instead is[1 2 1 2 1 2]
. As you would expect, if there are any specs configured the request would not be valid.To have a better understanding on what is happening I have the following tests:
As you can see from above the issue occurs when using
with-json-mixin
, but when leaving outwith-json-encoder
andwith-json-decoder
everything seems to be working as expected. It may seem as the issue is somehow related to those 2 mixings even though they're not doing a lot apart from adding a map to the context. Something strange seems to happen within the merge-actions function as this is the point where those params values are being duplicatedand more specifically within the liberator
update-context
which seems to concatenate the vectors within the params unless it's explicitly decorated with thereplace
metadata as mentioned here. The params are decorated with thereplace
metadata, but withinwith-params-parsed-as-json
that's the last mixin to be added as part ofwith-json-mixin
and by then the params values have already been duplicated.As a workaround I've created an internal mixin that takes care of decorating the params with the
replace
metadata and placed it beforewith-json-mixin
:It would be great to see your thoughts on this, and if you need more details please let me know.
Thanks,
Cris
The text was updated successfully, but these errors were encountered: