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

Bug: Kafka envelope return an array of arrays of values #3488

Closed
dreamorosi opened this issue Jan 17, 2025 · 1 comment · Fixed by #3489
Closed

Bug: Kafka envelope return an array of arrays of values #3488

dreamorosi opened this issue Jan 17, 2025 · 1 comment · Fixed by #3489
Assignees
Labels
bug Something isn't working parser This item relates to the Parser Utility pending-release This item has been merged and will be released soon

Comments

@dreamorosi
Copy link
Contributor

Expected Behavior

When parsing an event coming from Kafka, either Self managed or from MSK, the schemas for the Parser utility should return a list of values. These values should be coming from the items within each record and should be base64-decoded into strings.

Current Behavior

Currently the result of the parsing is this: [['{"key":"value"}']] aka an array of arrays with the values inside.

This is because during our initial implementation we followed the event structure and assumed that there was a relationship many:many between the record keys and the record items. I.e. considering the following sample event:

{
  "eventSource": "aws:kafka",
  "eventSourceArn": "arn:aws:kafka:us-east-1:0123456789019:cluster/SalesCluster/abcd1234-abcd-cafe-abab-9876543210ab-4",
  "bootstrapServers": "b-2.demo-cluster-1.a1bcde.c1.kafka.us-east-1.amazonaws.com:9092,b-1.demo-cluster-1.a1bcde.c1.kafka.us-east-1.amazonaws.com:9092",
  "records": {
    "mytopic-0": [
      {
        "topic": "mytopic",
        "partition": 0,
        "offset": 15,
        "timestamp": 1545084650987,
        "timestampType": "CREATE_TIME",
        "key": "cmVjb3JkS2V5",
        "value": "eyJrZXkiOiJ2YWx1ZSJ9",
        "headers": [
          {
            "headerKey": [104, 101, 97, 100, 101, 114, 86, 97, 108, 117, 101]
          }
        ]
      }
    ]
  }
}

We wrote the envelope result to accommodate the potential of multiple groups of values, one for each record, with a record being mytopic-0 and it having a list of items.

In reality this can never happen in Lambda because the integration enforces a relationship between 1 topic and one consumer, so in practice the result can be flattened to a simple list of values, i.e. ['{"key":"value"}'].

Code snippet

N/A

Steps to Reproduce

N/A

Possible Solution

No response

Powertools for AWS Lambda (TypeScript) version

latest

AWS Lambda function runtime

22.x

Packaging format used

npm

Execution logs

@dreamorosi dreamorosi added bug Something isn't working confirmed The scope is clear, ready for implementation parser This item relates to the Parser Utility labels Jan 17, 2025
@dreamorosi dreamorosi self-assigned this Jan 17, 2025
@dreamorosi dreamorosi moved this from Triage to Pending review in Powertools for AWS Lambda (TypeScript) Jan 17, 2025
@github-project-automation github-project-automation bot moved this from Pending review to Coming soon in Powertools for AWS Lambda (TypeScript) Jan 20, 2025
Copy link
Contributor

⚠️ COMMENT VISIBILITY WARNING ⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or 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 github-actions bot added pending-release This item has been merged and will be released soon and removed confirmed The scope is clear, ready for implementation labels Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parser This item relates to the Parser Utility pending-release This item has been merged and will be released soon
Projects
Status: Coming soon
Development

Successfully merging a pull request may close this issue.

1 participant