Skip to content
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

Error with version 2.0.2 when multi-value header is active in alb #909

Closed
LennardWolf2023 opened this issue Jun 19, 2024 · 6 comments
Closed

Comments

@LennardWolf2023
Copy link

LennardWolf2023 commented Jun 19, 2024

Serverless Java Container version: 2.0.2

Implementations: Spring Boot 3

Framework version: SpringBoot 3.2.6.RELEASE

Frontend service: ALB|RestController

Deployment method: AWS Cloud Development Kit

Scenario

We tried to migrate the server less java container spring boot version we are using from version 2.0.1 to 2.0.2. We are using the framework for our lambda which is accessible by an alb, which has a certain target groups, that directs the calls to the corresponding lambda. The lambda provides a spring @RestController with Post and Get Mappings. With version 2.0.1 everything worked fine.

Expected behavior

By increasing the version in the build gradle dependencies, we wanted to migrate to the new version without any additional workaround or further action.

Actual behavior

When multi-header value (attribute on target group of lambda: lambda.multi_value_headers.enabled) are configured in the alb, the requests directing to lambda are answered with HTTP status code 502. The error occurs, when the lambda should be invoked by a HTTP request to its endpoints. Please see stack trace in full log output.

Steps to reproduce

Create a lambda with corresponding 2.0.2 version of framework, that is invoked by an alb and target group that the user can the endpoint provided by the lambdas @RestController. The multi-value headers need to be activated at the target group level.
For the setup description in https://github.com/aws/serverless-java-container/wiki/Quick-start---Spring-Boot3 is used as template.

Full log output

java.lang.NullPointerException: Cannot invoke "com.amazonaws.serverless.proxy.model.SingleValueHeaders.get(Object)" because the return value of "com.amazonaws.serverless.proxy.model.AwsProxyRequest.getHeaders()" is null
	at com.amazonaws.serverless.proxy.internal.servlet.AwsProxyHttpServletRequest.getRemoteHost(AwsProxyHttpServletRequest.java:450)
	at org.springframework.http.server.reactive.ServletServerHttpRequest.getRemoteAddress(ServletServerHttpRequest.java:192)
	at org.springframework.http.server.reactive.DefaultServerHttpRequestBuilder.<init>(DefaultServerHttpRequestBuilder.java:76)
	at org.springframework.http.server.reactive.ServerHttpRequest.mutate(ServerHttpRequest.java:106)
	at org.springframework.http.server.reactive.ContextPathCompositeHandler.lambda$handle$1(ContextPathCompositeHandler.java:73)
	at java.base/java.util.Optional.map(Unknown Source)
	at org.springframework.http.server.reactive.ContextPathCompositeHandler.handle(ContextPathCompositeHandler.java:71)
	at org.springframework.boot.web.reactive.context.WebServerManager$DelayedInitializationHttpHandler.handle(WebServerManager.java:98)
	at org.springframework.http.server.reactive.ServletHttpHandlerAdapter.service(ServletHttpHandlerAdapter.java:199)
	at com.amazonaws.serverless.proxy.spring.embedded.ServerlessReactiveServletEmbeddedServerFactory.service(ServerlessReactiveServletEmbeddedServerFactory.java:71)
	at com.amazonaws.serverless.proxy.internal.servlet.FilterChainManager$ServletExecutionFilter.doFilter(FilterChainManager.java:374)
	at com.amazonaws.serverless.proxy.internal.servlet.FilterChainHolder.doFilter(FilterChainHolder.java:90)
	at com.amazonaws.serverless.proxy.internal.servlet.AwsLambdaServletContainerHandler.doFilter(AwsLambdaServletContainerHandler.java:154)
	at com.amazonaws.serverless.proxy.spring.SpringBootLambdaContainerHandler.handleRequest(SpringBootLambdaContainerHandler.java:183)
	at com.amazonaws.serverless.proxy.spring.SpringBootLambdaContainerHandler.handleRequest(SpringBootLambdaContainerHandler.java:56)
	at com.amazonaws.serverless.proxy.internal.LambdaContainerHandler.proxy(LambdaContainerHandler.java:215)
	at com.amazonaws.serverless.proxy.internal.LambdaContainerHandler.proxyStream(LambdaContainerHandler.java:258)
	at com.example.myapplication.StreamLambdaHandler.handleRequest(StreamLambdaHandler.kt:33)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at com.amazonaws.services.lambda.runtime.api.client.EventHandlerLoader$StreamMethodRequestHandler.handleRequest(EventHandlerLoader.java:379)
	at com.amazonaws.services.lambda.runtime.api.client.EventHandlerLoader$2.call(EventHandlerLoader.java:907)
	at com.amazonaws.services.lambda.runtime.api.client.AWSLambda.startRuntime(AWSLambda.java:239)
	at com.amazonaws.services.lambda.runtime.api.client.AWSLambda.startRuntime(AWSLambda.java:191)
	at com.amazonaws.services.lambda.runtime.api.client.AWSLambda.main(AWSLambda.java:181)
@deki
Copy link
Collaborator

deki commented Jun 19, 2024

Thanks for the bug report.

@mbfreder this looks like a regression related to #816, #827. Can you take a look please?

@deki
Copy link
Collaborator

deki commented Jun 19, 2024

@LennardWolf2023 a fix has been merged to 2.0.x and main branch. Can you please validate it using a SNAPSHOT build?

We plan to ship a 2.0.3 release tomorrow.

@LennardWolf2023
Copy link
Author

@deki thank you for the fast response. We tried to find the corresponding snapshot, but were only able to find a snapshot for archetype underneath https://aws.oss.sonatype.org/content/repositories/snapshots, but not the spring boot3 version. Do you have a link, where we can find the snapshot.

@LennardWolf2023
Copy link
Author

We also saw, that the release 2.0.3 was initiated. When the package is available, we try it out using the release.

@deki
Copy link
Collaborator

deki commented Jun 20, 2024

Yeah I just triggered it. Should be in Maven Central soon.

@deki
Copy link
Collaborator

deki commented Jun 20, 2024

Release is there now. Please let us now if you still see any issues.

@deki deki closed this as completed Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants