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

pydantic.v1.error_wrappers isn’t present in Pydantic 1.10.15 #9625

Closed
6 of 15 tasks
shikha372 opened this issue Jun 10, 2024 · 2 comments
Closed
6 of 15 tasks

pydantic.v1.error_wrappers isn’t present in Pydantic 1.10.15 #9625

shikha372 opened this issue Jun 10, 2024 · 2 comments
Labels
bug V1 Bug related to Pydantic V1.X pending Awaiting a response / confirmation

Comments

@shikha372
Copy link

Initial Checks

  • I have searched GitHub for a duplicate issue and I'm sure this is something new
  • I have searched Google & StackOverflow for a solution and couldn't find anything
  • I have read and followed the docs and still think this is a bug
  • I am confident that the issue is with pydantic (not my code, or another library in the ecosystem like FastAPI or mypy)

Description

We are facing several test failures while using pydantic v=1.10.15 with AttributeError: module 'pydantic.v1' has no attribute 'error_wrappers' :

Current :
============================================================================ short test summary info =============================================================================
FAILED tests/model/test_resource_validator.py::TestResourceValidatorFailure::test_connector_with_empty_properties - AttributeError: module 'pydantic.v1' has no attribute 'error_wrappers'
FAILED tests/model/test_resource_validator.py::TestResourceValidatorFailure::test_connector_with_invalid_permission - AttributeError: module 'pydantic.v1' has no attribute 'error_wrappers'
FAILED tests/model/test_resource_validator.py::TestResourceValidatorFailure::test_connector_with_invalid_permission_type - AttributeError: module 'pydantic.v1' has no attribute 'error_wrappers'
FAILED tests/model/test_resource_validator.py::TestResourceValidatorFailure::test_connector_without_source - AttributeError: module 'pydantic.v1' has no attribute 'error_wrappers'
FAILED tests/translator/test_translator.py::test_transform_invalid_document[error_graphqlapi] - AttributeError: module 'pydantic.v1' has no attribute 'error_wrappers'
=============================================================== 5 failed, 3967 passed, 5 rerun in 75.20s (0:01:15) ===============================================================
make: **

Expected:
Class 'error_wrappers' should be imported in pydantic.v1 version 1.10.15 so that this runs as expected in version 1.10.14

TOTAL 9365 267 3768 224 96%

Required test coverage of 95% reached. Total coverage: 95.83%

Line of code where this error type check is defined in our package:
https://github.com/aws/serverless-application-model/blob/develop/samtranslator/model/__init__.py#L348

Example Code

Line of code where this error type check is defined in our package: 
https://github.com/aws/serverless-application-model/blob/develop/samtranslator/model/__init__.py#L348

Import defined here
https://github.com/aws/serverless-application-model/blob/44562dc000b991b99c80798e4a35ff9fbe8397d9/samtranslator/compat.py#L1-L6


    def validate_properties_and_return_model(self, cls: Type[RT]) -> RT:
        """
        Given a resource properties, return a typed object from the definitions of SAM schema model

        param:
            resource_properties: properties from input template
            cls: schema models
        """
        try:
            return cls.parse_obj(self._generate_resource_dict()["Properties"])
        except pydantic.error_wrappers.ValidationError as e:
            error_properties: str = ""
            with suppress(KeyError):
                error_properties = ".".join(str(x) for x in e.errors()[0]["loc"])
            raise InvalidResourceException(self.logical_id, f"Property '{error_properties}' is invalid.") from e

Steps to reproduce:

$ gh repo clone aws/serverless-application-model
$ cd serverless-application-model
$ python3 -m venv _e
$ . _e/bin/activate
(_e) $ pip install -e '.[dev]'
(_e) $ pip install pydantic==1.10.15
(_e) $ make test



### Python, Pydantic & OS Version

```Text
(_e) shikagg@bcd07410a1df serverless-application-model % python -c "import pydantic.utils; print(pydantic.utils.version_info())"
             pydantic version: 1.10.15
            pydantic compiled: False
                 install path: /Users/shikagg/serverless-application-model/_e/lib/python3.12/site-packages/pydantic
               python version: 3.12.3 (main, Apr  9 2024, 08:09:14) [Clang 15.0.0 (clang-1500.3.9.4)]
                     platform: macOS-14.3.1-arm64-arm-64bit
     optional deps. installed: ['typing-extensions']

Affected Components

@hramezani
Copy link
Member

Thanks @shikha372 for reporting this issue.

I think the problem has already been addressed in pydantc 1.10.X-fixes. this is the branch that we release the 1.10.x from it.
Please test the branch and confirm the fix. Then we will release 1.10.16 soon.

@sydney-runkle
Copy link
Member

@hramezani,

Thanks for looking into this! I agree, that PR should have fixed this issue, and we'll release said fix soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug V1 Bug related to Pydantic V1.X pending Awaiting a response / confirmation
Projects
None yet
Development

No branches or pull requests

3 participants