You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Short version:
An unversioned S3 object create message is sent to SQS. SQS message body is read into object using var event = software.amazon.awssdk.eventnotifications.s3.model.S3EventNotification.fromJson(). event is written back into a string using event.toJson() and put into an SQS message and put on the queue. When reading the new SQS message body using S3EventNotification.fromJson(), it fails with java.lang.IllegalArgumentException: 'versionId' was not a string
Long version:
I have an S3 bucket that sends notifications to an SQS queue on object create. The S3 object has no version. Because the S3 object has no version, there is no value for Records[0].S3.S3Object.versionId. It is not present in the JSON body.
I get the SQS message and read its body (a string) into an S3EventNotification using software.amazon.awssdk.eventnotifications.s3.model.S3EventNotification.fromJson(message.getBody()).
eventNotification.getRecords().get(0).getS3().getObject().getVersionId() correctly returns null, because there was no value in the JSON body.
I attempt to process the S3 object. If I am unable to do so, I create a new message and put it back on the SQS queue. I create the SQS message body by doing eventNotification.toJson(). This string this creates includes "versionId":null in Records[0].S3.S3Object.versionId.
When I get the re-queued message from SQS, I am unable to parse it with software.amazon.awssdk.eventnotifications.s3.model.S3EventNotification.fromJson(message.getBody()), failing with java.lang.IllegalArgumentException: 'versionId' was not a string
Regression Issue
Select this option if this issue appears to be a regression.
Expected Behavior
I would expect to be able to:
read a valid S3 Event Notification JSON string into an object S3EventNotification.fromJson()
write the object back into a string using S3EventNotification.toJson()
read that string again using S3EventNotification.fromJson()
Current Behavior
Currently:
read a valid S3 Event Notification JSON string into an object S3EventNotification.fromJson()
write the object back into a string using S3EventNotification.toJson()
read that string again using S3EventNotification.fromJson() fails because the string has "versionId":null, and versionId must be a string.
Reproduction Steps
public void eventBodyTest() {
var msgBodyNoVersionId = "{\"Records\":[{\"eventVersion\":\"event version\",\"eventSource\":\"event source\",\"awsRegion\":\"us-east-1\",\"eventTime\":\"2024-11-26T23:12:22Z\",\"eventName\":\"ObjectCreated:Put\",\"userIdentity\":{\"principalId\":\"principalId\"},\"requestParameters\":{\"sourceIPAddress\":\"sourceIpAddress\"},\"responseElements\":{\"x-amz-request-id\":\"xAmzRequestId\",\"x-amz-id-2\":\"xamzid2\"},\"s3\":{\"s3SchemaVersion\":\"s3SchemaVersion\",\"configurationId\":\"configId\",\"bucket\":{\"name\":\"mock-recordings\",\"ownerIdentity\":{\"principalId\":\"principalId\"},\"arn\":\"arn\"},\"object\":{\"key\":\"screenrecordings/f797615450ca4d57955d46d0/ac204e68-517c-4b64-aa58-462d0aece2cb//recoding.webm\",\"size\":0,\"eTag\":\"etag\",\"sequencer\":\"sequencer\"}},\"glacierEventData\":{\"restoreEventData\":{\"lifecycleRestorationExpiryTime\":\"2024-11-26T23:12:22Z\",\"lifecycleRestoreStorageClass\":\"lifecycleStorageClass\"}},\"replicationEventData\":{\"replicationRuleId\":\"replicationRuleId\",\"destinationBucket\":\"destinationBucket\",\"s3Operation\":\"s3Operation\",\"requestTime\":\"requestTime\",\"failureReason\":\"failureReason\",\"threshold\":\"threshold\",\"replicationTime\":\"replicationTime\"},\"intelligentTieringEventData\":{\"destinationAccessTier\":\"destinationAccessTier\"},\"lifecycleEventData\":{\"transitionEventData\":{\"destinationStorageClass\":\"destinationStorageClass\"}}}]}";
var msg = S3EventNotification.fromJson(msgBodyNoVersionId);
var msgStr = msg.toJson();
var msg2 = S3EventNotification.fromJson(msgStr);
return;
}
Possible Solution
Ignore null values when parsing the JSON string, or remove them before parsing.
Additional Information/Context
No response
AWS Java SDK version used
2.26.20
JDK version used
openjdk 17.0.7 2023-04-18
Operating System and version
macOS Sonoma Version 14.6.1
The text was updated successfully, but these errors were encountered:
zakeckert
changed the title
(short issue description)
S3EventNotification cannot take an unversioned S3EvetnNotification fromJson() -> toJson() -> fromJson()
Nov 26, 2024
zakeckert
changed the title
S3EventNotification cannot take an unversioned S3EvetnNotification fromJson() -> toJson() -> fromJson()
S3EventNotification cannot take an unversioned S3EventNotification fromJson() -> toJson() -> fromJson()
Nov 26, 2024
debora-ito
added
investigating
This issue is being investigated and/or work is in progress to resolve the issue.
p2
This is a standard priority issue
and removed
needs-triage
This issue or PR still needs to be triaged.
labels
Dec 3, 2024
Describe the bug
Short version:
An unversioned S3 object create message is sent to SQS. SQS message body is read into object using
var event = software.amazon.awssdk.eventnotifications.s3.model.S3EventNotification.fromJson()
.event
is written back into a string usingevent.toJson()
and put into an SQS message and put on the queue. When reading the new SQS message body usingS3EventNotification.fromJson()
, it fails withjava.lang.IllegalArgumentException: 'versionId' was not a string
Long version:
I have an S3 bucket that sends notifications to an SQS queue on object create. The S3 object has no version. Because the S3 object has no version, there is no value for
Records[0].S3.S3Object.versionId
. It is not present in the JSON body.I get the SQS message and read its body (a string) into an
S3EventNotification
usingsoftware.amazon.awssdk.eventnotifications.s3.model.S3EventNotification.fromJson(message.getBody())
.eventNotification.getRecords().get(0).getS3().getObject().getVersionId()
correctly returnsnull
, because there was no value in the JSON body.I attempt to process the S3 object. If I am unable to do so, I create a new message and put it back on the SQS queue. I create the SQS message body by doing
eventNotification.toJson()
. This string this creates includes"versionId":null
inRecords[0].S3.S3Object.versionId
.When I get the re-queued message from SQS, I am unable to parse it with
software.amazon.awssdk.eventnotifications.s3.model.S3EventNotification.fromJson(message.getBody())
, failing withjava.lang.IllegalArgumentException: 'versionId' was not a string
Regression Issue
Expected Behavior
I would expect to be able to:
read a valid S3 Event Notification JSON string into an object
S3EventNotification.fromJson()
write the object back into a string using
S3EventNotification.toJson()
read that string again using
S3EventNotification.fromJson()
Current Behavior
Currently:
read a valid S3 Event Notification JSON string into an object
S3EventNotification.fromJson()
write the object back into a string using
S3EventNotification.toJson()
read that string again using
S3EventNotification.fromJson()
fails because the string has"versionId":null
, andversionId
must be a string.Reproduction Steps
Possible Solution
Ignore null values when parsing the JSON string, or remove them before parsing.
Additional Information/Context
No response
AWS Java SDK version used
2.26.20
JDK version used
openjdk 17.0.7 2023-04-18
Operating System and version
macOS Sonoma Version 14.6.1
The text was updated successfully, but these errors were encountered: