Skip to content

Bug: EventBridge envelope reports incorrect path #3503

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

Closed
dreamorosi opened this issue Jan 20, 2025 · 2 comments · Fixed by #3504
Closed

Bug: EventBridge envelope reports incorrect path #3503

dreamorosi opened this issue Jan 20, 2025 · 2 comments · Fixed by #3504
Assignees
Labels
bug Something isn't working completed This item is complete and has been merged/shipped parser This item relates to the Parser Utility

Comments

@dreamorosi
Copy link
Contributor

Expected Behavior

When using the EventBridgeEnvelope to parse an event, the error returned by the envelope should contain the correct path so that customers can easily find the root cause of the issue.

Current Behavior

This is the error emitted:

ParseError: Failed to parse envelope. This error was caused by: [
  {
    "code": "invalid_type",
    "expected": "string",
    "received": "undefined",
    "path": [
      "name"
    ],
    "message": "Required"
  }
].

The correct path should be ["detail", "name"] since the validation applies to the detail field.

Code snippet

{
  "version": "0",
  "id": "6a7e8feb-b491-4cf7-a9f1-bf3703467718",
  "detail-type": "EC2 Instance State-change Notification",
  "source": "aws.ec2",
  "account": "111122223333",
  "time": "2017-12-22T18:43:48Z",
  "region": "us-west-1",
  "resources": [
    "arn:aws:ec2:us-west-1:123456789012:instance/i-1234567890abcdef0"
  ],
  "detail": {
    "instance_id": "i-1234567890abcdef0",
    "state": "terminated"
  },
  "replay-name": "replay_archive"
}

and using the following code:

const schema = z.object({
  'name': z.string()
});

const parsed = EventBridgeEnvelope.parse(event, schema);

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 20, 2025
@dreamorosi dreamorosi self-assigned this Jan 20, 2025
@dreamorosi dreamorosi moved this from Triage to Working on it in Powertools for AWS Lambda (TypeScript) Jan 20, 2025
@dreamorosi dreamorosi linked a pull request Jan 20, 2025 that will close this issue
@github-project-automation github-project-automation bot moved this from Working on it to Coming soon in Powertools for AWS Lambda (TypeScript) Jan 21, 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 21, 2025
Copy link
Contributor

This is now released under v2.13.1 version!

@github-actions github-actions bot added completed This item is complete and has been merged/shipped and removed pending-release This item has been merged and will be released soon labels Jan 28, 2025
@dreamorosi dreamorosi moved this from Coming soon to Shipped in Powertools for AWS Lambda (TypeScript) Jan 28, 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 completed This item is complete and has been merged/shipped parser This item relates to the Parser Utility
Projects
Development

Successfully merging a pull request may close this issue.

1 participant