aws-sdk-java icon indicating copy to clipboard operation
aws-sdk-java copied to clipboard

Unable to unmarshal S3 Event Notification

Open arivukkarasu2007 opened this issue 4 years ago • 3 comments

Describe the bug

While trying to unmarshal s3eventnotification message to S3EventNotification.S3EventNotificationRecord using below line, getting error. unmarshal().json(JsonLibrary.Jackson, S3EventNotification.S3EventNotificationRecord.class)

Expected Behavior

S3event message should unmarshal to the object.

Current Behavior

Getting below error. com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "Type" (class com.amazonaws.services.s3.event.S3EventNotification$S3EventNotificationRecord), not marked as ignorable (10 known properties: "s3", "awsRegion", "eventName", "eventTime", "responseElements", "requestParameters", "eventVersion", "eventSource", "userIdentity", "glacierEventData"])

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "Type" (class com.amazonaws.services.s3.event.S3EventNotification$S3EventNotificationRecord), not marked as ignorable (10 known properties: "s3", "awsRegion", "eventName", "eventTime", "responseElements", "requestParameters", "eventVersion", "eventSource", "userIdentity", "glacierEventData"])

Steps to Reproduce

Unmarshal the s3event notification using java application unmarshal().json(JsonLibrary.Jackson, S3EventNotification.S3EventNotificationRecord.class)

Possible Solution

There should be property to hold "Type" value or it should be under ignoreproperty.

Context

Your Environment

  • AWS Java SDK version used: 1.11.961
  • JDK version used: 1.8.181
  • Operating System and version: RHEL7

arivukkarasu2007 avatar Feb 25 '21 04:02 arivukkarasu2007

@arivukkarasu2007 can you please provide a minimal reproducible code?

I mean a full example, more than just this line:

unmarshal().json(JsonLibrary.Jackson, S3EventNotification.S3EventNotificationRecord.class)

debora-ito avatar Feb 27 '21 05:02 debora-ito

@debora-ito i am using Apache camel frame work to consume message from sqs queue , S3 notifications.

from(aws-sqs://) .unmarshal().json(JsonLibrary.Jackson, S3EventNotification.S3EventNotificationRecord.class)

Above is all the code.

arivukkarasu2007 avatar Feb 27 '21 21:02 arivukkarasu2007

@arivukkarasu2007 A few suggestions to help debug faster:

  1. Provide a sample record that can be used for testing.
  2. Have you tried deserializing it with Jackson without using Apache Camel? If not, how can we be sure that it is an issue with AWS-SDK rather than Apache Camel?
  3. From the code sample you have provided, it seems you are directly unmarshalling the raw message to S3EventNotificationRecord instead of extracting the value from it (i.e. MessageBody). Is that what could be causing this issue?

jashgala avatar May 10 '21 10:05 jashgala

Closing for staleness and low interest (upvotes or recent comments).

debora-ito avatar Mar 14 '23 01:03 debora-ito

COMMENT VISIBILITY WARNING

Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

github-actions[bot] avatar Mar 17 '23 02:03 github-actions[bot]