Skip to content

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

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

Closed
Alappin opened this issue Dec 23, 2020 · 7 comments

Comments

@Alappin
Copy link

Alappin commented Dec 23, 2020

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.

@msailes
Copy link
Collaborator

msailes commented Dec 23, 2020

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

@Alappin
Copy link
Author

Alappin commented Dec 24, 2020

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.

@Alappin
Copy link
Author

Alappin commented Dec 24, 2020

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.

@msailes
Copy link
Collaborator

msailes commented Dec 24, 2020

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

@Alappin
Copy link
Author

Alappin commented Dec 24, 2020

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.

This was referenced Dec 29, 2020
@msailes
Copy link
Collaborator

msailes commented Jul 9, 2021

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

@msailes
Copy link
Collaborator

msailes commented Aug 26, 2021

Released in 3.10.0

@msailes msailes closed this as completed Aug 26, 2021
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

No branches or pull requests

2 participants