Skip to content

Unrecognized field "version" in class com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent #207

Closed

Description

@Alappin

A deployed lambda written in java fails in API Gateway due to a missing version field. Error message is shown below:

Unrecognized field "version" (class com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent), not marked as ignorable (12 known properties: "requestContext", "body", "queryStringParameters", "path", "headers", "httpMethod", "multiValueQueryStringParameters", "resource", "pathParameters", "isBase64Encoded", "stageVariables", "multiValueHeaders"])

It seems the latest java lambda events is missing the "version" field hence the event cannot be serialized without throwing an exception.

Activity

  1. msailes commented on Dec 23, 2020

    @msailes
    Contributor

    Hi Alappin,

    Are you using version 2 of the API Gateway proxy integration?

    If you are that uses a different event which does have version

    https://github.com/aws/aws-lambda-java-libs/blob/master/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2HTTPEvent.java

    Mark

  2. Alappin commented on Dec 24, 2020

    @Alappin
    Author

    Hi @msailes

    For my AGW HTTP API, in my code, I am using the (APIGatewayProxyRequestEvent) with the format:

    { "resource": "Resource path", "path": "Path parameter", "httpMethod": "Incoming request's method name", ... }

    When I test this locally, I send requests with the below form to the lambda container image and this works

    { "path":"/api", "httpMethod": "POST", }

    However, when I deploy the lambda and have my Version 1 integration set in AGW, I get requests of the form:

    { "version": "1.0", "path":"/api", "httpMethod": "POST", }

    AGW adds the "version" tag regardless of whether its configured for V1 or V2 integration causing the lambda to fail because the "APIGatewayProxyRequestEvent" cannot serialize a "version" property.

    So I think, either AGW should be fixed to exclude "version" if configured for V1 or the lambda events package should add the "version" property so that it does not break when deployed. I hope my problem is clear.

  3. Alappin commented on Dec 24, 2020

    @Alappin
    Author

    Also checking the documentation on https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html#http-api-develop-integrations-lambda.proxy-format

    It shows that Apigateway will send the "version" property for both V1 and V2 integration types. This is a problem when lambda events library (APIGatewayProxyRequestEvent) does not have the property.

  4. msailes commented on Dec 24, 2020

    @msailes
    Contributor

    Does using v2 fix your problem while a fix is made for v1?

  5. Alappin commented on Dec 24, 2020

    @Alappin
    Author

    The code I am working with is just a demo for using lambda with containers so I am fine waiting for the fix and then applying it.

  6. msailes commented on Jul 9, 2021

    @msailes
    Contributor

    Hi @Alappin,

    Sorry for the confusing notifications you must be getting. I'm working on this atm and testing the various different scenarios. I'm hoping to sort this out soon.

    Mark

  7. msailes commented on Aug 26, 2021

    @msailes
    Contributor

    Released in 3.10.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions