aws-sam-cli: queryStringParams returns list of Strings
Description: We just upgraded to SAM CLI 0.3.0 and noticed a change with queryStringParams where the query parameter is mapping to an array of a strings instead of a string. For example:
0.2.11 mapping: {"name":"jason"}
0.3.0 mapping: {'name': [u'jason']}
.
We are using aws-serverless-java-container-jersey
from https://github.com/awslabs/aws-serverless-java-container and it seems to break when trying to map the query parameter to a string when our endpoint is defined as follows:
public Response getHelloWorld(@QueryParam("name") String name)
We are not sure if SAM CLI is supposed to return a list of strings for query parameters or just a single string? Looking at the tests it seems that the expected behavior would be that each query parameter maps to a string and not a list of strings. test_api_event() in test_events.py has an expected_event where: 'queryStringParameters': {'foo': 'bar'}
Steps to reproduce the issue:
- Create a proxy integration lambda that prints out the inputStream
- Call the new API endpoint with a query parameter and a value
Observed result: The query parameter is mapped to a list containing the value given
Output of sam --version
:
SAM CLI, version 0.3.0
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 4
- Comments: 15 (8 by maintainers)
Commits related to this issue
- fix: Value of QueryString in the API event should only be a string Fixes the bug reported in #404 — committed to jfuss/aws-sam-cli by jfuss 6 years ago
- fix: Value of QueryString in the API event should only be a string (#405) Fixes the bug reported in #404 — committed to aws/aws-sam-cli by jfuss 6 years ago
Fix is out for review. Updating labels.
@jonpierce I do not have an ETA yet. Going to poke some folks today in hopes to at least get it merged. I don’t expect us to do a release right after that is merged though. There are a couple other regressions/bugs we need to fix and I think getting those into one release is best.
We are still working on some of these process related things (cadence/criteria for a release is one of them). Once I have some clarity on that, I will update this issue so folks can at least understand when it will happen. Hopefully that helps.
As a heads-up, this bug also completely breaks golang lambda functions. Trying to pass any query parameter results in the following error:
I can confirm that @jfuss patch fixes the problem. Would love to get an ETA on release…
@mrchops1024 The best thing I can suggest is installing SAM CLI from source with my patch until we can get that PR merged and a release out. Sorry for the troubles this causes.
This was released in v0.4.0
Closing.
@jfuss That’s exactly what I did and so far there are no issues. Thanks.