mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(apigateway): take the last value of a repeated query string parameter (#3548)
A REST proxy event built queryStringParameters from the FIRST value of a
repeated parameter, so ?x=1&x=2&x=3 reached the integration as "1".
Captured against a real REST API in us-west-2 with a Lambda proxy
integration: AWS collapses a repeated parameter to the LAST value,
yielding {"x":"3"}, while multiValueQueryStringParameters keeps every
value in order as ["1","2","3"]. A trailing empty value still wins, so
?x=1&x= yields "".
This is the same rule putSingleValueHeaders already applies to duplicate
request headers one method above, where the comment notes that taking the
first value diverged from AWS. Query strings were left on the old
behaviour; they now match.
Also pins two properties that were already correct, so they stay that
way: a bracketed name such as filter[status]=open reaches the integration
unchanged, and an absent query string nulls both maps.
putQueryStringParameters and putMultiValueQueryStringParameters become
package-private for the unit test, matching putSingleValueHeaders and
putMultiValueHeaders next to them.
HTTP APIs are untouched. Their payload formats join duplicates with a
comma rather than taking one value, which is a different rule and is not
measured here.
This commit is contained in:
1 parent
bfe2b71587
commit
e8edc3d4b1
3 files changed
+181
-3
No files matched your search
+7
-3
@@ -1133,19 +1133,23 @@ public class ApiGatewayExecuteController {
|
||||
});
|
||||
}
|
||||
|
||||
private void putQueryStringParameters(ObjectNode event, UriInfo uriInfo) {
|
||||
void putQueryStringParameters(ObjectNode event, UriInfo uriInfo) {
|
||||
MultivaluedMap<String, String> queryParams = uriInfo.getQueryParameters();
|
||||
if (!queryParams.isEmpty()) {
|
||||
ObjectNode qsp = event.putObject("queryStringParameters");
|
||||
queryParams.forEach((name, values) -> {
|
||||
if (!values.isEmpty()) qsp.put(name, values.get(0));
|
||||
// AWS collapses a repeated query string parameter to the LAST value in the
|
||||
// single-value `queryStringParameters` map, exactly as it does for duplicate
|
||||
// headers above; multiValueQueryStringParameters keeps every value in order.
|
||||
// Taking the first value diverged from AWS: ?x=1&x=2&x=3 yields "3", not "1".
|
||||
if (!values.isEmpty()) qsp.put(name, values.get(values.size() - 1));
|
||||
});
|
||||
} else {
|
||||
event.putNull("queryStringParameters");
|
||||
}
|
||||
}
|
||||
|
||||
private void putMultiValueQueryStringParameters(ObjectNode event, UriInfo uriInfo) {
|
||||
void putMultiValueQueryStringParameters(ObjectNode event, UriInfo uriInfo) {
|
||||
MultivaluedMap<String, String> queryParams = uriInfo.getQueryParameters();
|
||||
if (!queryParams.isEmpty()) {
|
||||
ObjectNode mqsp = event.putObject("multiValueQueryStringParameters");
|
||||
|
||||
Reference in new issue
Block a user