LambdaContainerHandler - Error while mapping object to RequestType class

オープン
#494 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
aws, java, spring-boot
領域
api, backend, cloud

調査の方向性

LambdaContainerHandler.java:256 から開始し、StreamLambdaHandler.java:42 からのリクエストマッピング呼び出しを追跡します。提供された API Gateway ペイロードを使って報告された Spring Boot 2 のリクエストを再現し、入力がなぜ空の状態で Jackson に到達するのかを調査します。完了の条件は、エンドポイントが 502 ではなく HTTP 200 と期待される JSON を返すことです。

索引モデルが issue の本文から書いたものです。

説明

need feedback

To help us debug your issue fill in the basic information below using the options provided

Serverless Java Container version: 1.9

Implementations: Spring Boot 2

Framework version: SpringBoot 2.7.6.RELEASE

Frontend service: REST API

Deployment method: Console

Scenario

Describe what you are trying to accomplish
I have created an AP Gateway REST API which proxies to a Springboot Java application exposing differnet endpoints, mostly returning Monos and Fluxes. Payload inputted is below.
{ "resource": "/{proxy+}", "path": "/capitals", "httpMethod": "GET", "headers": { "Accept": "application/json", "Accept-Encoding": "gzip, deflate", "Cache-Control": "no-cache", "Content-Type": "application/json", "Host": "xxxxxxx.execute-api.eu-north-1.amazonaws.com", "Postman-Token": "zzzzzzz-4c21-4a6b-a71a-b5d39ce42332", "User-Agent": "PostmanRuntime/7.28.4", "X-Amzn-Trace-Id": "Root=1-638f4d15-626c445233b14ceb2f567363", "X-BlueCoat-Via": "0drrr83fc54be448", "X-Forwarded-For": "1.2.3.4", "X-Forwarded-Port": "443", "X-Forwarded-Proto": "https" }, "multiValueHeaders": { "Accept": [ "application/json" ], "Accept-Encoding": [ "gzip, deflate" ], "Cache-Control": [ "no-cache" ], "Content-Type": [ "application/json" ], "Host": [ "ay9vitrep4.execute-api.eu-north-1.amazonaws.com" ], "Postman-Token": [ "zzzzzzz-4c21-4a6b-a71a-b5d39ce42332" ], "User-Agent": [ "PostmanRuntime/7.28.4" ], "X-Amzn-Trace-Id": [ "Root=1-638f4d15-626c445233b14ceb2f567363" ], "X-BlueCoat-Via": [ "ggg3fc54be448" ], "X-Forwarded-For": [ "1.2.3.4" ], "X-Forwarded-Port": [ "443" ], "X-Forwarded-Proto": [ "https" ] }, "queryStringParameters": null, "multiValueQueryStringParameters": null, "pathParameters": { "proxy": "capitals" }, "stageVariables": null, "requestContext": { "resourceId": "sm5w9j", "resourcePath": "/{proxy+}", "httpMethod": "GET", "extendedRequestId": "cuj7cEsTgi0FkCA=", "requestTime": "06/Dec/2022:14:09:25 +0000", "path": "/dev/capitals", "accountId": "123456789", "protocol": "HTTP/1.1", "stage": "dev", "domainPrefix": "ay9vitrep4", "requestTimeEpoch": 1670335765833, "requestId": "50facc59-b889-44a0-8a58-f86431bf0897", "identity": { "cognitoIdentityPoolId": null, "accountId": null, "cognitoIdentityId": null, "caller": null, "sourceIp": "1.2.3.4", "principalOrgId": null, "accessKey": null, "cognitoAuthenticationType": null, "cognitoAuthenticationProvider": null, "userArn": null, "userAgent": "PostmanRuntime/7.28.4", "user": null }, "domainName": "xxxxxxxxx.execute-api.eu-north-1.amazonaws.com", "apiId": "xxxxxxxx" }, "body": null, "isBase64Encoded": false }

Nevertheless, when executing the endpoint, the call fails as seems that above payload cannot be mapped into a RequestType class (which is an AWSProxyRequest)

[main] ERROR com.amazonaws.serverless.proxy.internal.LambdaContainerHandler - Error while mapping object to RequestType class
  | 2022-12-06T15:38:16.811+01:00 | com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input

Expected behavior

Describe how you would expect the application to behave
Json Payload should be returned with 200 response

Actual behavior

Describe what you are seeing instead
Response returns 502 with this error inCloudwatch:

[main] ERROR com.amazonaws.serverless.proxy.internal.LambdaContainerHandler - Error while mapping object to RequestType class   | 2022-12-06T15:38:16.811+01:00 | com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input

Steps to reproduce

Provide code samples we can use to reproduce the issue as part of our integration tests. If there is a public repository for the misbehaving application link to it here

  1. Added aws-serverless-java-container springboot2 library in pom, version 1.9
    2)Added LambdaHandler as below
public class StreamLambdaHandler implements RequestStreamHandler {
    private static SpringBootLambdaContainerHandler<AwsProxyRequest, AwsProxyResponse> handler;
    static {
        try {
            handler = SpringBootLambdaContainerHandler.getAwsProxyHandler(Application.class);
            // If you are using HTTP APIs with the version 2.0 of the proxy model, use the getHttpApiV2ProxyHandler
            // method: handler = SpringBootLambdaContainerHandler.getHttpApiV2ProxyHandler(Application.class);
        } catch (ContainerInitializationException e) {
            // if we fail here. We re-throw the exception to force another cold start
            e.printStackTrace();
            throw new RuntimeException("Could not initialize Spring Boot application", e);
        }
    }

    @Override
    public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context)
            throws IOException {
        handler.proxyStream(inputStream, outputStream, context);
    }
}

3)Add typical Application (annotated with @SpringBootpplication) + a RestController with this class:

@RestController
public class Resource {

    private AService service;

    public Resource1(AService service) {
        this.service = service;
    }
    
    @GetMapping("/capitals")
    public Mono<Capitals> getMono() {
        return service.serve()
                .collectList()
                .map(Capitals::new);
    }
    
    @Data
    private class Capitals {
        final List<String> values;
    }
}

Service class:

@Service
public class AService {

    public static final List<String> capitals = Arrays.asList("Copenhagen", "Rome", "Berlin", "Reykjavik");

    public Flux<String> serve() {
        return Flux.fromIterable(capitals);
    }
}
```



## Full log output
*Paste the full log output from the Lambda function's CloudWatch logs*

```
<html>
<body>
<!--StartFragment-->

2022-12-06T15:38:16.811+01:00 | 14:38:16.811 [main] ERROR com.amazonaws.serverless.proxy.internal.LambdaContainerHandler - Error while mapping object to RequestType class
-- | --
  | 2022-12-06T15:38:16.811+01:00 | com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
  | 2022-12-06T15:38:16.811+01:00 | at [Source: (ByteArrayInputStream); line: 1, column: 0]
  | 2022-12-06T15:38:16.811+01:00 | at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
  | 2022-12-06T15:38:16.811+01:00 | at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1741)
  | 2022-12-06T15:38:16.811+01:00 | at com.fasterxml.jackson.databind.ObjectReader._initForReading(ObjectReader.java:359)
  | 2022-12-06T15:38:16.811+01:00 | at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:2041)
  | 2022-12-06T15:38:16.811+01:00 | at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1427)
  | 2022-12-06T15:38:16.811+01:00 | at com.amazonaws.serverless.proxy.internal.LambdaContainerHandler.proxyStream(LambdaContainerHandler.java:256)
  | 2022-12-06T15:38:16.811+01:00 | at com.nordea.ndf.lambda.StreamLambdaHandler.handleRequest(StreamLambdaHandler.java:42)
  | 2022-12-06T15:38:16.811+01:00 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  | 2022-12-06T15:38:16.811+01:00 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  | 2022-12-06T15:38:16.811+01:00 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  | 2022-12-06T15:38:16.811+01:00 | at java.base/java.lang.reflect.Method.invoke(Unknown Source)
  | 2022-12-06T15:38:16.811+01:00 | at lambdainternal.EventHandlerLoader$StreamMethodRequestHandler.handleRequest(EventHandlerLoader.java:375)
  | 2022-12-06T15:38:16.811+01:00 | at lambdainternal.EventHandlerLoader$2.call(EventHandlerLoader.java:899)
  | 2022-12-06T15:38:16.811+01:00 | at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:268)
  | 2022-12-06T15:38:16.811+01:00 | at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:206)
  | 2022-12-06T15:38:16.811+01:00 | at lambdainternal.AWSLambda.main(AWSLambda.java:200)
  | 2022-12-06T15:38:16.811+01:00 | 14:38:16.811 [main] ERROR com.amazonaws.serverless.proxy.AwsProxyExceptionHandler - Called exception handler for:
  | 2022-12-06T15:38:16.811+01:00 | com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
  | 2022-12-06T15:38:16.811+01:00 | at [Source: (ByteArrayInputStream); line: 1, column: 0]
  | 2022-12-06T15:38:16.811+01:00 | at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
  | 2022-12-06T15:38:16.811+01:00 | at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1741)
  | 2022-12-06T15:38:16.811+01:00 | at com.fasterxml.jackson.databind.ObjectReader._initForReading(ObjectReader.java:359)
  | 2022-12-06T15:38:16.811+01:00 | at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:2041)
  | 2022-12-06T15:38:16.811+01:00 | at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1427)
  | 2022-12-06T15:38:16.811+01:00 | at com.amazonaws.serverless.proxy.internal.LambdaContainerHandler.proxyStream(LambdaContainerHandler.java:256)
  | 2022-12-06T15:38:16.811+01:00 | at com.nordea.ndf.lambda.StreamLambdaHandler.handleRequest(StreamLambdaHandler.java:42)
  | 2022-12-06T15:38:16.811+01:00 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  | 2022-12-06T15:38:16.811+01:00 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  | 2022-12-06T15:38:16.811+01:00 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  | 2022-12-06T15:38:16.811+01:00 | at java.base/java.lang.reflect.Method.invoke(Unknown Source)
  | 2022-12-06T15:38:16.811+01:00 | at lambdainternal.EventHandlerLoader$StreamMethodRequestHandler.handleRequest(EventHandlerLoader.java:375)
  | 2022-12-06T15:38:16.811+01:00 | at lambdainternal.EventHandlerLoader$2.call(EventHandlerLoader.java:899)
  | 2022-12-06T15:38:16.811+01:00 | at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:268)
  | 2022-12-06T15:38:16.811+01:00 | at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:206)
  | 2022-12-06T15:38:16.811+01:00 | at lambdainternal.AWSLambda.main(AWSLambda.java:200)
  | 2022-12-06T15:38:16.812+01:00 | com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
  | 2022-12-06T15:38:16.812+01:00 | at [Source: (ByteArrayInputStream); line: 1, column: 0]
  | 2022-12-06T15:38:16.812+01:00 | at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
  | 2022-12-06T15:38:16.812+01:00 | at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1741)
  | 2022-12-06T15:38:16.812+01:00 | at com.fasterxml.jackson.databind.ObjectReader._initForReading(ObjectReader.java:359)
  | 2022-12-06T15:38:16.812+01:00 | at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:2041)
  | 2022-12-06T15:38:16.812+01:00 | at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1427)
  | 2022-12-06T15:38:16.812+01:00 | at com.amazonaws.serverless.proxy.internal.LambdaContainerHandler.proxyStream(LambdaContainerHandler.java:256)
  | 2022-12-06T15:38:16.812+01:00 | at com.nordea.ndf.lambda.StreamLambdaHandler.handleRequest(StreamLambdaHandler.java:42)
  | 2022-12-06T15:38:16.812+01:00 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  | 2022-12-06T15:38:16.812+01:00 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  | 2022-12-06T15:38:16.828+01:00 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  | 2022-12-06T15:38:16.848+01:00 | at java.base/java.lang.reflect.Method.invoke(Unknown Source)
  | 2022-12-06T15:38:16.848+01:00 | at lambdainternal.EventHandlerLoader$StreamMethodRequestHandler.handleRequest(EventHandlerLoader.java:375)
  | 2022-12-06T15:38:16.848+01:00 | at lambdainternal.EventHandlerLoader$2.call(EventHandlerLoader.java:899)
  | 2022-12-06T15:38:16.848+01:00 | at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:268)
  | 2022-12-06T15:38:16.848+01:00 | at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:206)

<!--EndFragment-->
</body>
</html>
```
主要言語
Java
スター
1.6k
フォーク
575
平均マージ
1日 15時間
マージ済み PR(30日)
12

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

aws/serverless-java-container のほかの issue

aws/serverless-java-container の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。