hoverfly icon indicating copy to clipboard operation
hoverfly copied to clipboard

Multiple entries of the same query parameter are encoded using ; (semicolon)

Open perlun opened this issue 6 years ago • 2 comments

Description of the bug

In commit 1276c03cf5315658bc14c87c504b68d58ba03258 (PR #794), we fixed #792. However, the fix is still not optimal since query parameters where either part of the key=value part includes semicolon will be unable to be represented in the simulation JSON.

To be honest, my use case don't have a requirement to use semicolons at the moment. However, I see a risk with the current implementation in that it uses a separator which could potentially be a fully valid part of a query parameter for a "reserved" purpose like this. This could potentially be very confusing to our users.

Ideally, the values would be present multiple times in the JSON (i.e. no separator), but if this is considered too complex/time consuming, we should at the very least choose a separator which is more than a single character. ;;; would be an improvement (note, this is just a suggestion; feel free to come up with a better option if you like)

Steps to reproduce the issue

Make a query which includes the same query string multiple times. Like this: http://localhost/some-api/some-resource?q=access:vod&q=order:latest&q=profile:vd

Observed result

"q": [
    {
        "matcher": "exact",
        "value": "access:vod;order:latest;profile:vd"
    }

Hoverfly error messages seen (If none, say none)

none

If possible, add screenshots to help explain your problem

Expected result

"q": [
    {
        "matcher": "exact",
        "value": "access:vod;;;order:latest;;;profile:vd"
    }

or (preferably):

"q": [
    {
        "matcher": "exact",
        "value": "access:vod"
    },
    {
        "matcher": "exact",
        "value": "order:latest"
    },
    {
        "matcher": "exact",
        "value": "profile:vd"
    }

or even this (I think this would be my personal favorite, in terms of readability of the JSON):

"q": [
    {
        "matcher": "exact",
        "value": [
            "access:vod",
            "order:latest",
            "profile:vd"
        ]
    }

Additional relevant information

  1. Hoverfly version:
+----------+--------------+
| hoverctl | master-3141  |
| hoverfly | v1.0.0-rc.2  |
+----------+--------------+
  1. Anything that might help us to diagnose the problem

perlun avatar May 31 '19 06:05 perlun

Hi @perlun, joining multiple values using a symbol for a query is not a permanent solution, we prefer to implement what you suggest as well:

"q": [
    {
        "matcher": "exact",
        "value": [
            "access:vod",
            "order:latest",
            "profile:vd"
        ]
    }

We thought about this before, and the value field is an interface type in the data model, so that it can be an array.

There will be matcher types that are specific to array values, like contains, containsExactly or containsOnly.

tommysitu avatar May 31 '19 09:05 tommysitu

@tommysitu Sounds great! As noted, it's not a huge problem for me at the moment but it was just something we discovered internally when we figured out how it's currently serialized to the JSON.

Btw, thanks for a great product! :+1:

perlun avatar May 31 '19 11:05 perlun

Hi, is this fixed?

Or some way working with queries like: q=access:vod&q=order:latest&q=profile:vd](http://localhost/some-api/some-resource?q=access:vod&q=order:latest&q=profile:vd

ahll avatar Dec 22 '22 17:12 ahll

@tommysitu I can work on this issue and fix this in above mentioned way. You can assign this issue to me.

kapishmalik avatar Dec 23 '22 13:12 kapishmalik

@kapishmalik that'll be awesome!

tommysitu avatar Dec 23 '22 13:12 tommysitu

@tommysitu Work is in progress. Can you mark this as WIP or assign this issue to me?

kapishmalik avatar Dec 23 '22 16:12 kapishmalik

@tommysitu Raised PR

kapishmalik avatar Dec 23 '22 19:12 kapishmalik

Thanks @kapishmalik your PR looks good!

tommysitu avatar Dec 28 '22 16:12 tommysitu

@tommysitu I feel I need to relook at contains and containsonly matcher. I am confused with existing implementation. I will raise PR to fix those.

kapishmalik avatar Dec 28 '22 20:12 kapishmalik

@tommysitu can you check this PR and review implementations and if they make more sense now.

kapishmalik avatar Dec 28 '22 21:12 kapishmalik

Thanks @tommysitu with reviews. I believe we are good with this issue now.

kapishmalik avatar Dec 28 '22 21:12 kapishmalik

@perlun this is done. You can use and let us know inase of any issues.

kapishmalik avatar Jan 03 '23 17:01 kapishmalik