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

Parser (Pydantic) re-export Pydantic errors for data model validation #1687

Closed
1 of 2 tasks
kPOWz opened this issue Nov 7, 2022 · 4 comments · Fixed by #1728
Closed
1 of 2 tasks

Parser (Pydantic) re-export Pydantic errors for data model validation #1687

kPOWz opened this issue Nov 7, 2022 · 4 comments · Fixed by #1728
Labels
feature-request feature request parser Parser (Pydantic) utility

Comments

@kPOWz
Copy link

kPOWz commented Nov 7, 2022

Use case

When writing validators and root validators it is useful to keep error formats consistent with the Pydantic TypeErrors and ValueErrors from the Pydantic errors module

Due to how Pydantic is packaged, these errors are not exported by https://github.com/awslabs/aws-lambda-powertools-python/blob/develop/aws_lambda_powertools/utilities/parser/pydantic.py#L5

https://awslabs.github.io/aws-lambda-powertools-python/2.1.0/utilities/parser/#data-model-validation

Solution/User Experience

re-export the LPT packaged Pydantic errors module under from aws_lambda_powertools.utilities.parser.pydantic.errors

ensure this will still work smoothly after switch to rust / pydantic core

Alternative solutions

No response

Acknowledgment

@kPOWz kPOWz added feature-request feature request triage Pending triage from maintainers labels Nov 7, 2022
@heitorlessa
Copy link
Contributor

heitorlessa commented Nov 16, 2022

Hey @kPOWz, would this work?

image

Looking at Pydantic exported symbols, there doesn't seem to be any clash so I can export them directly too.

https://github.com/awslabs/aws-lambda-powertools-python/pull/1728/files#diff-802361d017af63e8fc18b5df568bbdfc17800ab8b90ef502a64a907ce4ef917bR9

@heitorlessa heitorlessa added parser Parser (Pydantic) utility and removed triage Pending triage from maintainers labels Nov 16, 2022
@heitorlessa
Copy link
Contributor

Just read Pydantic V2 plan and the only breaking change it seems to apply here is parse_raw that we use in Parser. I couldn't find a specific mention on errors packaging.

I'll go ahead and merge the errors exposing, since parser.pydantic.errors wouldn't work as it's not a package and doesn't seem to need to be.

Because it's a major version, we will come to that when we need to cross that bridge. I think there's a great chance in the future to make Pydantic built-in in Powertools to ease developing certain features like Feature Flags - the benchmarks and reduced package size look fantastic, but we need to apply due-diligence and weigh its pros/cons as usual.

@heitorlessa heitorlessa linked a pull request Nov 17, 2022 that will close this issue
7 tasks
@github-actions
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 the pending-release Fix or implementation already in dev waiting to be released label Nov 17, 2022
@github-actions
Copy link
Contributor

This is now released under 2.3.0 version!

@github-actions github-actions bot removed the pending-release Fix or implementation already in dev waiting to be released label Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request feature request parser Parser (Pydantic) utility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants