Closed jmalins closed 3 months ago
Feel free to propose a PR.
Thanks, will do. I have a workaround for now, but expect one in the next few days.
Hi @jmalins can you please share your workaround ? I'm facing the same issue with commas
I'm not sure if this is an intended behavior but I realised that the query string translation is mutating the original event
argument passed to the lambda.
For example if you pass &key=a%2Cb
:
When logging request.awsLambda.event
you will get
{key: ["a","b"]}
even though the original event passed from API gateway is:
{"key": "a,b"}
This was confusing in our case because it made my team doubt that API gateway itself was transforming the query
I submitted a PR to address this behavior ( within the scope of the querystring ). and added a new option to allow users to opt-out from the current behaviour without causing any breaking changes for existing users
related to https://github.com/fastify/aws-lambda-fastify/issues/125 @maxkre96
The current query string translation logic doesn't distinguish between repeated query string values (i.e.
&key=a&key=b
) and values that contain URL encoded literal commas (i.e.&key=a%2Cb
). The former should map to a fastify array value, the latter should not. It appears the API GW V2.0 event format has this same hazard.The two cases could be distinguished by parsing the
rawQueryString
value (or for performance reasons, doing this only when a potential split is detected).https://github.com/fastify/aws-lambda-fastify/blob/2e9387bfc8172be360c1bac997db216f7535d7fa/index.js#L65