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

SpringDelegatingLambdaContainerHandler seems does not work with query parameters #754

Closed
astsiatsko opened this issue Jan 30, 2024 · 8 comments · Fixed by #755
Closed

SpringDelegatingLambdaContainerHandler seems does not work with query parameters #754

astsiatsko opened this issue Jan 30, 2024 · 8 comments · Fixed by #755
Assignees
Milestone

Comments

@astsiatsko
Copy link

Hello to everyone.
Spring boot 3.1.0
aws-serverless-java-container-springboot3:2.0.0-M2
Frontend service: ALB, API_GW, Functional URL
Deployment method: terraform or manual

Scenario

I want my java lambda microservice to process all types of events without additional expenses: ALB, API_GW, HTTP, Functional URL

Expected behavior

Behave the same way to all event types listed above

Actual behavior

When I use SpringDelegatingLambdaContainerHandler, I get error 400 every time I have query parameters for ALB event. if I use functional url event, I get internal server error.

Steps to reproduce

@RequestMapping(path = "/w6/test/{uuid}/refresh", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<TMaxmindResponse> refresh( @Parameter(description = "UUID of the order") @PathVariable("uuid") String uuid, @Parameter(description = "ID of the order(primary key)") @RequestParam("order_id") Long orderId, @Parameter(description = "tab") @RequestParam("tab") String tab )

Full log output

jakarta.servlet.ServletException: Request processing failed: java.lang.NullPointerException: Cannot read the array length because \"\u003cparameter1\u003e\" is null\n\tat org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1019)\n\tat org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:903)\n\tat jakarta.servlet.http.HttpServlet.service(HttpServlet.java:527)\n\tat org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885)\n\tat jakarta.servlet.http.HttpServlet.service(HttpServlet.java:614)\n\tat org.springframework.cloud.function.serverless.web.ProxyMvc$ProxyFilterChain$ServletFilterProxy.doFilter(ProxyMvc.java:280)\n\tat org.springframework.cloud.function.serverless.web.ProxyMvc$ProxyFilterChain.doFilter(ProxyMvc.java:233)\n\tat org.springframework.web.filter.AbstractRequestLoggingFilter.doFilterInternal(AbstractRequestLoggingFilter.java:289)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)\n\tat org.springframework.cloud.function.serverless.web.ProxyMvc$ProxyFilterChain.doFilter(ProxyMvc.java:233)\n\tat org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)\n\tat org.springframework.cloud.function.serverless.web.ProxyMvc$ProxyFilterChain.doFilter(ProxyMvc.java:233)\n\tat org.springframework.web.filter.ServerHttpObservationFilter.doFilterInternal(ServerHttpObservationFilter.java:109)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)\n\tat org.springframework.cloud.function.serverless.web.ProxyMvc$ProxyFilterChain.doFilter(ProxyMvc.java:233)\n\tat org.springframework.cloud.function.serverless.web.ProxyMvc.service(ProxyMvc.java:144)\n\tat org.springframework.cloud.function.serverless.web.ProxyMvc.service(ProxyMvc.java:138)\n\tat com.amazonaws.serverless.proxy.spring.SpringDelegatingLambdaContainerHandler.handleRequest(SpringDelegatingLambdaContainerHandler.java:74)\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)\n\tat java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)\n\tat java.base/java.lang.reflect.Method.invoke(Unknown Source)\n\tat com.amazonaws.services.lambda.runtime.api.client.EventHandlerLoader$StreamMethodRequestHandler.handleRequest(EventHandlerLoader.java:378)\n\tat com.amazonaws.services.lambda.runtime.api.client.EventHandlerLoader$2.call(EventHandlerLoader.java:905)\n\tat com.amazonaws.services.lambda.runtime.api.client.AWSLambda.startRuntime(AWSLambda.java:245)\n\tat com.amazonaws.services.lambda.runtime.api.client.AWSLambda.startRuntime(AWSLambda.java:197)\n\tat com.amazonaws.services.lambda.runtime.api.client.AWSLambda.main(AWSLambda.java:187)\nCaused by: java.lang.NullPointerException: Cannot read the array length because \"\u003cparameter1\u003e\" is null\n\tat java.base/java.io.ByteArrayInputStream.\u003cinit\u003e(Unknown Source)\n\tat org.springframework.cloud.function.serverless.web.ProxyHttpServletRequest.getInputStream(ProxyHttpServletRequest.java:280)\n\tat org.springframework.web.util.ContentCachingRequestWrapper.getInputStream(ContentCachingRequestWrapper.java:98)\n\tat org.springframework.http.server.ServletServerHttpRequest.getBody(ServletServerHttpRequest.java:206)\n\tat org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver$EmptyBodyCheckingHttpInputMessage.\u003cinit\u003e(AbstractMessageConverterMethodArgumentResolver.java:323)\n\tat org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters(AbstractMessageConverterMethodArgumentResolver.java:172)\n\tat org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.readWithMessageConverters(RequestResponseBodyMethodProcessor.java:163)\n\tat org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.resolveArgument(RequestResponseBodyMethodProcessor.java:136)\n\tat org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:122)\n\tat org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:181)\n\tat org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:148)\n\tat org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:118)\n\tat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:884)\n\tat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)\n\tat org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)\n\tat org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1081)\n\tat org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:974)\n\tat org.springframework.web.servlet.FrameworkServlet.processReque

I tried to wrap my head around it for 2 or 3 days, and found that when it tries to do

mvc.service(httpServletRequest, httpServletResponse);

it fails to error 400, no matter which parameters are. Also, if method parameters marked as optional, it returns exception and error 500, for instance, @RequestParam("order_id") Optional<Long> orderId,

After spending that much time, I decided that this is a bug and I really appreciate if this bug is resolved ASAP. Thanks

@deki deki added this to the Release 2.0 milestone Jan 30, 2024
olegz added a commit to olegz/aws-serverless-java-container that referenced this issue Jan 30, 2024
While concentrating on REST we somehow ignored standard request parameters. This fix addresses it for both v1 and v2 requests as well as adds tests and additional endpoint to a sample to verify

Resolves aws#754
olegz added a commit to olegz/aws-serverless-java-container that referenced this issue Jan 30, 2024
While concentrating on REST we somehow ignored standard request parameters. This fix addresses it for both v1 and v2 requests as well as adds tests and additional endpoint to a sample to verify

Resolves aws#754

polishing
@deki deki closed this as completed in #755 Jan 30, 2024
deki added a commit that referenced this issue Jan 30, 2024
GH-754 Fix request parameter parsing
@astsiatsko
Copy link
Author

Hey guys, how may I include this fix in maven? Which version to use?

@deki
Copy link
Collaborator

deki commented Jan 31, 2024

It will be 2.0.0 but it's not released yet (likely beginning of next week).

@astsiatsko
Copy link
Author

Thanks, will it be a new version like -M3?

@deki
Copy link
Collaborator

deki commented Jan 31, 2024

No it will be the stable release without a milestone.

@deki
Copy link
Collaborator

deki commented Jan 31, 2024

You can clone the repo and build from source if you want to validate the fix now.

@astsiatsko
Copy link
Author

astsiatsko commented Jan 31, 2024

Yes but my question was - if I will wait for release on the next seek, will it be publicly available in maven central, etc?

@deki
Copy link
Collaborator

deki commented Jan 31, 2024

Yes, 2.0.0 will be also available on Maven Central.

@astsiatsko
Copy link
Author

Thank you

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

Successfully merging a pull request may close this issue.

3 participants