Skip to content

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

Closed

Description

@kPOWz

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

Activity

  1. heitorlessa commented on Nov 16, 2022

    @heitorlessa
    Contributor

    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

  2. added
    parserParser (Pydantic) utility
    and removed
    triagePending triage from maintainers
    on Nov 16, 2022
  3. heitorlessa commented on Nov 17, 2022

    @heitorlessa
    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.

  4. github-actions commented on Nov 17, 2022

    @github-actions
    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.

  5. github-actions commented on Nov 17, 2022

    @github-actions
    Contributor

    This is now released under 2.3.0 version!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions