-
Notifications
You must be signed in to change notification settings - Fork 563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request Parameters not picked up for v1 payload format with multivalue headers enabled #1256
Comments
I thought perhaps it can be solved with this change: @SuppressWarnings({ "unchecked", "rawtypes" })
private static HttpServletRequest generateRequest1(String request, Context lambdaContext,
SecurityContextWriter securityWriter, ObjectMapper mapper, ServletContext servletContext) {
AwsProxyRequest v1Request = readValue(request, AwsProxyRequest.class, mapper);
ServerlessHttpServletRequest httpRequest = new ServerlessHttpServletRequest(servletContext, v1Request.getHttpMethod(), v1Request.getPath());
if(v1Request.getMultiValueQueryStringParameters() != null) {
populateQueryStringParameters1(v1Request.getMultiValueQueryStringParameters(), httpRequest);
}
if (v1Request.getMultiValueHeaders() != null) {
MultiValueMapAdapter headers = new MultiValueMapAdapter(v1Request.getMultiValueHeaders());
httpRequest.setHeaders(headers);
}
if (StringUtils.hasText(v1Request.getBody())) {
httpRequest.setContentType("application/json");
httpRequest.setContent(v1Request.getBody().getBytes(StandardCharsets.UTF_8));
}
if (v1Request.getRequestContext() != null) {
httpRequest.setAttribute(RequestReader.API_GATEWAY_CONTEXT_PROPERTY, v1Request.getRequestContext());
httpRequest.setAttribute(RequestReader.ALB_CONTEXT_PROPERTY, v1Request.getRequestContext().getElb());
}
httpRequest.setAttribute(RequestReader.API_GATEWAY_STAGE_VARS_PROPERTY, v1Request.getStageVariables());
httpRequest.setAttribute(RequestReader.API_GATEWAY_EVENT_PROPERTY, v1Request);
httpRequest.setAttribute(RequestReader.LAMBDA_CONTEXT_PROPERTY, lambdaContext);
httpRequest.setAttribute(RequestReader.JAX_SECURITY_CONTEXT_PROPERTY,
securityWriter.writeSecurityContext(v1Request, lambdaContext));
return httpRequest;
} and private static void populateQueryStringParameters1(MultiValuedTreeMap<String, String> requestParameters, ServerlessHttpServletRequest httpRequest) {
if (!CollectionUtils.isEmpty(requestParameters)) {
for (Entry<String, List<String>> entry : requestParameters.entrySet()) {
String[] array = entry.getValue().toArray(new String[0]);
httpRequest.setParameter(entry.getKey(), array);
}
}
} But I'm not 100% if this is the correct approach. |
…ivalue headers enabled - removed unused imports (#1256)
Thanks for the bug report. I pushed a fix but noticed the test coverage is insufficient. These behaviors were already implemented for the old request mapping in https://github.com/aws/serverless-java-container/blob/main/aws-serverless-java-container-core/src/test/java/com/amazonaws/serverless/proxy/internal/servlet/AwsProxyHttpServletRequestTest.java and both logic and tests should be carried over to the new Spring-specific part. |
Hi @deki , thanks for the quick fix on that! Any chance we could get an updated version of this? We've currently moved our request parameters to header values, but it's not great. Even a snapshot version would help. |
Sure, will provide you a 2.1.2 release within the next days. |
2.1.2 is released. Created #1278 for test coverage and additional related fixes. |
Awesome! Thanks again @deki for the quick action on this! |
Serverless Java Container version: 2.1.1
Implementations: Spring Boot 3
Framework version: SpringBoot 3.4.0
Frontend service: ALB / Function URL
Deployment method: CDK
Similar to the issue here #1229, when we enable multivalue headers in target group, no request parameters are picked up.
When we enable multivalue headers, the headers aren't populated like:
Instead, they are populated in a
multiValueQueryStringParameters
block, like this:The code in
AwsSpringHttpProcessingUtils
, especially thegenerateRequest1
method, doesn't use themultiValueQueryStringParameters
, but it's using the following code:It would be great if this could be resolved.
The text was updated successfully, but these errors were encountered: