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
Wow would be really nice to get this merged in!
I am also waiting for this to get merged.
Is there an ETA on this merge?
@sapessi any chance we can get this merged before the next release?
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.
Any update ?
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...
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 https://github.com/awslabs/aws-serverless-express/pull/291 gets merged ?
Hello, is there some workaround that can be used while waiting for this issue to be fixed?
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.
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...
:tada: This issue has been resolved in version 4.1.1 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
Most helpful comment
Wow would be really nice to get this merged in!