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

Feature request: add custom Error for envelopes #1822

Closed
1 of 2 tasks
am29d opened this issue Dec 19, 2023 · 3 comments
Closed
1 of 2 tasks

Feature request: add custom Error for envelopes #1822

am29d opened this issue Dec 19, 2023 · 3 comments
Assignees
Labels
confirmed The scope is clear, ready for implementation feature-request This item refers to a feature request for an existing or new utility parser This item relates to the Parser Utility

Comments

@am29d
Copy link
Contributor

am29d commented Dec 19, 2023

Use case

When parsing custom schema in the envelope we currently propagate any error from zod back to the user. When there is an error, the mental process is first to localise it between envelope or custom schema. We should provide a custom Error that clearly points out which part of the structure is invalid. This will allow to faster resolution of the error.

Solution/User Experience

No solution yet.

Alternative solutions

No response

Acknowledgment

Future readers

Please react with 👍 and your use case to help us understand customer demand.

@am29d am29d added triage This item has not been triaged by a maintainer, please wait feature-request This item refers to a feature request for an existing or new utility labels Dec 19, 2023
@am29d am29d added need-customer-feedback Requires more customers feedback before making or revisiting a decision discussing The issue needs to be discussed, elaborated, or refined parser This item relates to the Parser Utility revisit-in-3-months Blocked issues/PRs that need to be revisited and removed triage This item has not been triaged by a maintainer, please wait labels Dec 19, 2023
@dreamorosi dreamorosi moved this from Backlog to Ideas in Powertools for AWS Lambda (TypeScript) Dec 19, 2023
@dreamorosi dreamorosi changed the title Feature request: add customer Error for envelopes Feature request: add custom Error for envelopes Dec 22, 2023
@dreamorosi
Copy link
Contributor

Revisiting this after a few months since the last interaction.

So far, most likely due to the utility being in beta, there hasn't been much demand for this.

We'll check back in a few months to see if things have changed, in the meanwhile Zod might have launched its next major version which is expected to include changes to the errors API.

@dreamorosi dreamorosi added revisit-in-3-months Blocked issues/PRs that need to be revisited and removed revisit-in-3-months Blocked issues/PRs that need to be revisited labels Jul 30, 2024
@dreamorosi dreamorosi added confirmed The scope is clear, ready for implementation and removed need-customer-feedback Requires more customers feedback before making or revisiting a decision discussing The issue needs to be discussed, elaborated, or refined revisit-in-3-months Blocked issues/PRs that need to be revisited labels Jan 23, 2025
@dreamorosi dreamorosi self-assigned this Jan 23, 2025
@dreamorosi dreamorosi moved this from Ideas to Backlog in Powertools for AWS Lambda (TypeScript) Jan 23, 2025
@dreamorosi
Copy link
Contributor

As part of a bug bash and refactoring of envelopes we have been making it so errors thrown by any of the envelopes are ParserError instances that contain the ZodError as cause. Both errors are customized to their respective envelopes and include contextual info like the index of Record in a SQS queue where appropriate. Below an example:

new ParseError('Failed to parse API Gateway body', {
  cause: new ZodError([
    {
      code: 'invalid_type',
      expected: 'string',
      received: 'undefined',
      path: ['path'],
      message: 'Required',
    },
    {
      code: 'invalid_type',
      expected: 'object',
      received: 'null',
      path: ['body'],
      message: 'Expected object, received null',
    },
  ]),
})

With this in mind, I'm closing the issue as completed since we have improved on the previous DX.

If anyone reads this issue in the future and would like to propose further improvements or changes to how we enhance Zod errors, please feel free to open a discussion.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed The scope is clear, ready for implementation feature-request This item refers to a feature request for an existing or new utility parser This item relates to the Parser Utility
Projects
Status: Coming soon
Development

No branches or pull requests

2 participants