-
Notifications
You must be signed in to change notification settings - Fork 566
Description
To help us debug your issue fill in the basic information below using the options provided
Serverless Java Container version: 1.7
Implementations: Spring Boot 2
Framework version: SpringBoot 2.6
Frontend service: HTTP API
Deployment method: ECR
Scenario
When calling lambda from apigateway (http, request v2), cookies are not processed by spring since servletrequest.getCookies
will always return empty array (https://github.com/awslabs/aws-serverless-java-container/blame/9af380bef32e5412aa69d6674387e85a908aca9e/aws-serverless-java-container-core/src/main/java/com/amazonaws/serverless/proxy/internal/servlet/AwsHttpApiV2ProxyHttpServletRequest.java#L76-L83).
The input from apigateway looks like this:
{
"version": "2.0",
"routeKey": "GET /test",
"rawPath": "/test",
"rawQueryString": "",
"cookies": [
"TEST=TEST"
],
"headers": {
"accept": "*/*",
"content-length": "0",
...
Note that the cookie values are under its own key instead of in headers.
Issue likely affects other frameworks as well, as the class is shared. Possibly causes #274
Expected behavior
Spring becomes aware of input cookies to apigateway.
Actual behavior
Spring is not aware of input cookies.
Steps to reproduce
Any http apigateway with lambda integration, with payload format version = 2.0
Without extensive testing, extending and using a custom AwsHttpApiV2ProxyHttpServletRequest
with the following implementation seems to work:
@Override
public Cookie[] getCookies() {
return req.getCookies().stream()
.map(c -> {
String[] parts = c.split("=");
return parts.length == 2 ? new Cookie(parts[0], parts[1]) : null;
})
.filter(c -> (c != null))
.toArray(Cookie[]::new);
}
Also consider aggregating the cookie values from the header (the current implementation) for compatibility.
Full log output
Paste the full log output from the Lambda function's CloudWatch logs
logs