Skip to content
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

Not getting records for S3Event (version 2.1) #481

Open
konstantinj opened this issue Jun 6, 2024 · 1 comment
Open

Not getting records for S3Event (version 2.1) #481

konstantinj opened this issue Jun 6, 2024 · 1 comment

Comments

@konstantinj
Copy link

I have issues getting my s3 event to run in my tests. I've captured this event from an actual file uploaded to my bucket.
Using the event from #187 is working for me - I get 1 record out of it.

Why is my event no working?

    @ParameterizedTest
    @Event(value = "test_s3_event.json", type = S3Event.class)
    public void testHandleRequest(S3Event s3Event) throws Exception {
        log.info("records: {}", String.valueOf(s3Event.getRecords().size()));
        ...
{
  "records": [
    {
      "awsRegion": "eu-central-1",
      "eventName": "ObjectCreated:Put",
      "eventSource": "aws:s3",
      "eventTime": 1717616806478,
      "eventVersion": "2.1",
      "requestParameters": {
        "sourceIPAddress": "127.0.0.1"
      },
      "responseElements": {
        "xAmzId2": "HS/nsizcytYaTZTVS6Wp9bdGtqcFSZCZkkCjNFJlHV6qhAWA4eLTjp+f26A1v86EyUSK5V9p+ajpnMaDKFUvX8twd3TlR1iB",
        "xAmzRequestId": "78T4D27EB3E35ECE"
      },
      "s3": {
        "configurationId": "NWIxNzFhZjUtYjNiOC00OTQ0LTlkODctYzhhYWMwZjAyNTRk",
        "bucket": {
          "name": "XXXXXX",
          "ownerIdentity": {
            "principalId": "ARYPPZZK7WW18"
          },
          "arn": "arn:aws:s3:::XXXXXX"
        },
        "object": {
          "key": "events/incoming/tracking_events.jsonl",
          "size": 3955,
          "eTag": "db53c028474115bd80133bac8a7a952a",
          "versionId": "",
          "sequencer": "006660C0A66E018430",
          "urlDecodedKey": "events/incoming/tracking_events.jsonl",
          "sizeAsLong": 3955
        },
        "s3SchemaVersion": "1.0"
      },
      "userIdentity": {
        "principalId": "AWS:AROA2KCWJBBZLKXQRZC6W:XXXXXX"
      }
    }
  ]
}

@stevenl
Copy link

stevenl commented Aug 29, 2024

I just faced this issue myself. The problem is not a bug in your code, but that the request data does not match the API. records is required to be capitalized:

{
  "Records": [
    {
      "awsRegion": "eu-central-1",
      ...
}

For reference, see https://docs.aws.amazon.com/AmazonS3/latest/userguide/notification-content-structure.html

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