fix: forward single-value query params in awslambda MultiValueQueryStringParameters - #8
Conversation
…ringParameters valuesToMultiMap only populated MultiValueQueryStringParameters with query keys that had more than one value; it skipped any key with a single value (len(value) == 1). The receiver (aws-lambda-go-api-proxy core/request.go) reads MultiValueQueryStringParameters exclusively once it is non-empty, so any request that carried at least one multi-value query parameter silently dropped every single-value parameter before it reached the Lambda. Include single-value params as 1-element slices (drop the len(value) == 1 condition) so every query key is forwarded, matching real AWS API Gateway semantics. Update Test_AWSLambdaMiddleware_InvokeBasic so the fixture expects the single-value keys alongside the multi-value ones, and add an assertion that no input query key is missing from the forwarded output. Signed-off-by: ahmedomosanya <aopeyemi@contractor.linuxfoundation.org>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
There was a problem hiding this comment.
Pull request overview
Fixes AWS Lambda query forwarding so multi-value parameters no longer cause single-value parameters to be dropped.
Changes:
- Includes all valid query parameters in the multi-value map.
- Updates regression coverage for mixed single- and multi-value queries.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
pkg/middlewares/awslambda/aws_lambda.go |
Forwards single-value query parameters as one-element slices. |
pkg/middlewares/awslambda/aws_lambda_test.go |
Verifies all query keys reach the Lambda request. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
pkg/middlewares/awslambda/aws_lambda.go:442
valuesToStringscan return(emptySlice, true)whenvalis a slice but all elements are filtered out as invalid. With the new condition,valuesToMultiMapwill now include those keys with an empty slice, which is typically not a meaningful forwarded query parameter and can change behavior downstream. Consider also skipping whenlen(value) == 0(or updatingvaluesToStringsto returnvalid=falsewhen no elements survive conversion) so only keys with at least one forwarded value are included.
values := map[string][]string{}
for name, val := range i {
value, valid := valuesToStrings(val)
if !valid {
continue
}
|
Waiting on GitHub actions to come back online so i can trigger the build and see tests pass before merging this in and getting it deployed. |
|
Closing and re-opening to trigger builds |
Summary
valuesToMultiMapinpkg/middlewares/awslambda/aws_lambda.goexcluded everysingle-value query parameter (
len(value) == 1), soMultiValueQueryStringParameterswas only ever populated with multi-value keys. Because the receiver
(
aws-lambda-go-api-proxycore/request.go) readsMultiValueQueryStringParametersexclusively once it is non-empty, any request with ≥1 multi-value parameter
silently dropped all single-value parameters before they reached the Lambda.
This forwards single-value params as 1-element slices as well, so every query key
is present — matching real AWS API Gateway semantics.
Change
Test
Test_AWSLambdaMiddleware_InvokeBasic(pkg/middlewares/awslambda/aws_lambda_test.go):MultiValueQueryStringParametersnow expects the single-value keys(
{"a":{"1"}, "b":{"2"}, "c":{"3","4"}, "d[]":{"5","6"}}) rather than only themulti-value ones.
go test ./pkg/middlewares/awslambda/...green.Note
Consumers that pin a built image of this fork will need to rebuild and redeploy to
pick up the change.