Skip to content

[BUG] NullPointerException on S3 Delete Event Due to Null Object Size #5448

@jmsusanto

Description

@jmsusanto

Describe the bug
When processing S3 delete events, data-prepper throws a NullPointerException because the object size is null.

To Reproduce

  1. Configure an S3 bucket with SQS Event Notifcations and ObjectDelete enabled.
  2. Delete a file from the monitored S3 bucket.
  3. The following error will occur:
    [s3-source-sqs-1] ERROR org.opensearch.dataprepper.plugins.source.s3.SqsWorker - Unable to process SQS messages. Processing error due to: Cannot invoke "java.lang.Long.longValue()" because the return value of "org.opensearch.dataprepper.plugins.source.s3.S3EventNotification$S3ObjectEntity.getSizeAsLong()" is null

Pipeline config:

  S3-pipeline:
    source:
      s3:
        notification_type: sqs
        codec:
          csv:
        compression: none
        sqs:
          queue_url: "https://sqs.us-east-2.amazonaws.com/someQueue"
        aws:
          region: "us-east-2"
          sts_role_arn: "someArn"

    sink:
      - stdout:

Expected behavior
The application should gracefully handle S3 delete events without throwing an exception. The object size should default to 0 when not present in the event notification.

Proposed Fix

  • Add a null check for getSizeAsLong() in the ParsedMessage class.
  • Default object size to 0L if the value is null.

Environment (please complete the following information):

  • OS: MacOS 14.7 Sonoma
  • Data Prepper 2.10.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions