james-proxy / james

Web Debugging Proxy Application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Request Query Params" use multiple parameters to display errors

loveyu opened this issue · comments

"Request Query Params" use multiple parameters to display errors

eg: property_id=123&property_id=456

error display:

property_id: 123456

suggest:

property_id: 123
property_id: 456

In the case of multiple query parameters with the same name, they're in more of an array form.
I'm thinking of having this print like:

property_id: 123,456

We came across a situation where the passed arguments are of the form but not an array.

property_id=19248&property_id=20321

NOT Like:

property_id[]=19248&property_id[]=20321

If I use array form, I won't be able to pass parameter validation, this is limited by third-party APIs.

However, this is just a display issue and does not cause any exceptions.

Ah, yes, I understand, I didn't explain properly.
I mean, if you have a URL like: http://website.com/endpoint?property_id=123&property_id=456, then I want to display it like:

property_id: 123,456

Does that sound good?

I feel like referring to the Chrome browser example, https://www.example.com/?property_id=123&property_id=456&property_ids[]=789&property_ids[A]=000

Display:

property_id: 123
property_id: 456
property_ids[]: 789
property_ids[A]: 000

When the array becomes multi-dimensional, the situation may be more complex if merged display is used.

Hmm, good point.
Right now, our underlying proxy that provides us the data is the tool that parses the query parameters, as viewed in the docs here. It's the underlying proxy that handles ?property_id[0]=123&property_id[1]=456 and ?property=123&property=456 differently:

// hoxy
// ?property_id[0]=123&property_id[1]=456
{
    'property_id[0]': 123,
    'property_id[1]': 456
}

// ?property=123&property=456
{
    'property_id': [123, 456]
}

We have a couple solutions to this:

  • Make the adjustment so we don't join arrays improperly - so, instead of the output being property_id: 123456, it will be: property_id: [123, 456] (PR #400)
  • Add a library that handles parsing query parameters (not a fan, since the benefit isn't much greater than the first option, and then we're shipping two query parameter parsers in James)
  • The first option, then handle this directly later in #401

Display to property_id: [123, 456], the most direct solution. I think the first thing is not to be misleading, the display mode can be flexible.

I've made a follow-up for this ticket, but since the core issue has been addressed, I'll close this.