aws-lambdaaws-api-gatewaymicronautmicronaut-aws

Micronaut Lambda with proxy can't unmarshal object from json body io.micronaut.web.router.exceptions.UnsatisfiedRouteException


In a Micronaut Lambda with proxy integration I have a controller that should unmarshal JSON content into a Ping object:

@Controller("/ping")
class PingController {

    private val logger = LoggerFactory.getLogger(javaClass)

    @Get("/")
    fun getPing(@Header("Host") host: String): Ping {
        logger.info("Host Header {}", host)
        return Ping("myPing")
    }

    @Post("/")
    @Status(HttpStatus.CREATED)
    fun createPing(@Body ping: Ping): Ping {
        logger.info("ping {}", ping)
        return ping
    }
}

If I start this application as a local micronaut webapp I can execute this sucessfully:

curl -X POST localhost:8080/ping -d '{"value": "myvalue"}' -H "Content-type: application/json"

Log info:

INFO  m.aws.api2.poc.PingController - ping Ping(value=myvalue)

However when this controller method is invoked from the AWS API Manager passing the Content-Type header and the body info...

enter image description here

... it fails:


14:56:18
io.micronaut.web.router.exceptions.UnsatisfiedRouteException: Required argument [Ping ping] not specified

14:56:18
at io.micronaut.web.router.AbstractRouteMatch.execute(AbstractRouteMatch.java:279)

14:56:18
at io.micronaut.web.router.RouteMatch.execute(RouteMatch.java:122)

14:56:18
at io.micronaut.function.aws.proxy.MicronautLambdaContainerHandler.lambda$null$1(MicronautLambdaContainerHandler.java:240)

14:56:18
at io.reactivex.internal.operators.flowable.FlowableDefer.subscribeActual(FlowableDefer.java:35)

14:56:18
at io.reactivex.Flowable.subscribe(Flowable.java:14805)

14:56:18
at io.reactivex.Flowable.subscribe(Flowable.java:14752)

14:56:18
at io.micronaut.reactive.rxjava2.RxInstrumentedFlowable.subscribeActual(RxInstrumentedFlowable.java:68) 

Oddly enough, the marshalling of the Ping object in the @Get call works both as a webapp and as a lambda.

I've uploaded a sample project in Github: https://github.com/codependent/micronaut-aws-lambda-proxy


Solution

  • There was a bug in the micronaut-function-aws-api-proxy lib, I reported it (https://github.com/micronaut-projects/micronaut-aws/issues/10) and was fixed right away in io.micronaut.aws:micronaut-function-aws-api-proxy:1.1.0.RC1