serverless-java-container icon indicating copy to clipboard operation
serverless-java-container copied to clipboard

AwsSpringHttpProcessingUtils in module aws-serverless-java-container-springboot3 has a NullPointerException

Open digithead1011 opened this issue 6 months ago • 3 comments

Starting at line 127:

	if (v1Request.getMultiValueHeaders() != null) {

			MultiValueMapAdapter headers = new MultiValueMapAdapter(v1Request.getMultiValueHeaders());
			httpRequest.setHeaders(headers);
		}
        populateContentAndContentType(
                v1Request.getBody(),
                v1Request.getMultiValueHeaders().getFirst(HttpHeaders.CONTENT_TYPE),
                v1Request.isBase64Encoded(),
                httpRequest
        );

If v1Request.getMultiValueHeaders() returns null, the lines the first if block is skipped. In the call to populateContentAndContentType, getMultiValueHeaders() is referenced, resulting in a NullPointerException

digithead1011 avatar Jul 01 '25 15:07 digithead1011

Running into this with one of our APIs. Attempting to test a gateway method via the console without providing headers results in the following request being sent to our lambda:

Endpoint request body after transformations: {
  "resource":"[...]",
  "path":"[...]",
  "httpMethod":"GET",
  "headers":null,
  "multiValueHeaders":null,
  "queryStringParameters":null,
  "multiValueQueryStringParameters":null,
  "pathParameters":null,
  "stageVariables":null,
[...]

Notice how the values provided for headers and multiValueHeaders is null. This issue is present in at least versions 2.1.4 and 2.1.3. I haven't had time to test other versions.

We are currently blocked by this, any chance of getting this fixed with the next release? Thanks in advance.

Charentule avatar Jul 07 '25 09:07 Charentule

@Charentule that's exactly where I saw the problem as well. I need to add some more unit tests to make sure I don't foul things up, but as soon as I've done that and feel confident in the results, I will submit the PR for consideration by the admins. Thanks for letting me know that it wasn't just me having the issue. I was starting to question that.

digithead1011 avatar Jul 07 '25 12:07 digithead1011

@Charentule I have added more tests and resubmitted the PR for review and merging

digithead1011 avatar Jul 21 '25 15:07 digithead1011