When running API Gateway, query strings in the event object are automagically URL decoded but when using Application Load Balancer, they're not. This leads to a problem where the getQueryString function (here) ends up URL encoding ALB query strings twice. (more information can be found here)
Here's an example of what we get out when using these parameters ?single=value%20with%20spaces&multi[rise%20of%20planets]=hello%20world&multi[death%20of%20planets]=bye%20world running Laravel.
API Gateway

Application Load Balancer

From what I've found so far, there's no super clear way of figuring out if the invokation is from API Gateway or Application Load Balancer but what we could do is check the event and see if the API Gateway specific event properties are there or not and URL decode the result of the http_build_query once before returning it, if not from API Gateway. (event differences from SO)
I've temporarily solved this by overwriting the PhpFpm.php file before deploy where I wrap http_build_query in urldecode.
https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html
If the query parameters are URL-encoded, the load balancer does not decode them. You must decode them in your Lambda function.
So, unfortunately, we need to handle it in the lambda function runtime.
I've been using Lambda with Bref behind ALB quite a lot and I'm not sure why I've been oblivious to this issue.
Is there something specific my requests need in order to cause the problem? I use Laravel, is it relevant for the issue?
We have SPA sending lots of requests using axios and jquery and I never noticed anything regarding encoding. I'd like to better understand this problem in order to figure out if I might be a victim of it at some point
Should be fixed by #693
Most helpful comment
Should be fixed by #693