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

Does not support array query string parameters #214

Closed
drdator opened this issue Feb 26, 2019 · 12 comments
Closed

Does not support array query string parameters #214

drdator opened this issue Feb 26, 2019 · 12 comments

Comments

@drdator
Copy link

drdator commented Feb 26, 2019

aws-serverless-express cannot parse array query string parameters

For example ?a=1&a=2 exposes only {a: 1} to express. Normally this would result in {a: [1, 2]}

API Gateway supports array query string parameters using multiValueQueryStringParameters
instead of queryStringParameters.

https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#apigateway-multivalue-headers-and-parameters

drdator added a commit to drdator/aws-serverless-express that referenced this issue Feb 26, 2019
@autolistben
Copy link

Wow would be really nice to get this merged in!

@xintellion
Copy link

I am also waiting for this to get merged.

@alexmantaut
Copy link

Is there an ETA on this merge?

@alexmantaut
Copy link

@sapessi any chance we can get this merged before the next release?

@sapessi
Copy link
Contributor

sapessi commented Mar 26, 2020

Hi @alexmantaut. My next step is to start looking into the v4 branch and publish a major update to the library. I'll get this change in there.

@jvinai
Copy link

jvinai commented Apr 16, 2020

Any update ?

@alexmantaut
Copy link

Just opened a PR to formalise the solution @drdator suggested to the problem...

I tested the changes locally and with lambdas and it works perfectly.

If anyone else wants to test the changes it will also be good.

Thanks @drdator for the fix...

@smirkovic
Copy link

Hi @sapessi, any update on this ? You mentioned it will get merged with V4. Is there any ETA ? v4 branch looks like it wasn't updated in 10months.

Is there a chance that #291 gets merged ?

@pejulian
Copy link

Hello, is there some workaround that can be used while waiting for this issue to be fixed?

@pejulian
Copy link

After searching around the code a little, I came up with a temporary hack in my code that overrides the queryStringParameters field in the event to use multiValueQueryStringParameters instead.

import produce from 'immer';

// Do setup...

const nextEvent = produce(event, (draftEvent) => {
        // [22-05-2020]:
        // A bug in aws-serverless-express prevents proper
        // handling of multi value query string params.. Therefore, apply this hack to
        // force aws-serverless-express to take multi value query string params...
        // This hack should be removed after this issue is fixed:
        // https://github.com/awslabs/aws-serverless-express/issues/214
        // eslint-disable-next-line @typescript-eslint/no-explicit-any
        draftEvent.queryStringParameters = event.multiValueQueryStringParameters as any;
    });

// Return the new instance
return proxy(cachedServer, nextEvent, context, 'PROMISE').promise;

Perhaps this may help someone until the proper fix is published.

@alexmantaut
Copy link

Hi @pejulian,

For my project what I ended up doing is patching the library manually inside the node_modules dir, and converting that into a patch by using patch-package.

What patch-package does is, it creates a patch that gets applied after yarn install.

I know this is not an ideal solution, but this bug was wasting too much of my time on workarounds...

@github-actions
Copy link

github-actions bot commented Feb 2, 2021

🎉 This issue has been resolved in version 4.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

9 participants