-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
Initial Checks
- I confirm that I'm using Pydantic V2
Description
Good afternoon,
I'm currently trying to debug an error that I'm seeing within an application of mine. Sadly, the application itself is closed source, but the library it's using is open source. I haven't been able to produce this error outside of the application, but am seeing it consistently in our test suite so I wanted to report it in case you happened to see what was wrong where I don't.
The code in question is part of a Flask application which is converting data from the query string into the Pydantic model. It's doing this via the code:
data_grid_state_models = get_grid_models_from_request(
sort_model_key="sort_model[]",
filter_model_key="filter_model",
pagination_model_key=None,
default_timezone=UTC,
)The get_grid_models_from_request function is https://github.com/kkirsche/mui-data-grid/blob/a951ef8881163453cc3e934e0b67113b3bb4aa59/src/mui/v6/integrations/flask/request.py#L20
The return statement here failed when validating the RequestGridModels class with the following stack trace:
*** TypeError: expected str, bytes or os.PathLike object, not timezone
Traceback (most recent call last):
File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/projectname-g3Hahb8t-py3.12/lib/python3.12/site-packages/pydantic/main.py", line 209, in __init__
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/projectname-g3Hahb8t-py3.12/lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py", line 1659, in validate_str_is_valid_iana_tz
return ZoneInfo(value)
^^^^^^^^^^^^^^^
File "/Users/kkirsche/.asdf/installs/python/3.12.6/lib/python3.12/zoneinfo/_tzpath.py", line 73, in find_tzfile
_validate_tzfile_path(key)
File "/Users/kkirsche/.asdf/installs/python/3.12.6/lib/python3.12/zoneinfo/_tzpath.py", line 86, in _validate_tzfile_path
if os.path.isabs(path):
^^^^^^^^^^^^^^^^^^^
File "<frozen posixpath>", line 62, in isabs
Sorry I don't have more information. I'll keep trying to get a more minimal reproduction for you. This only occurred when updating our Pydantic version from 2.8.2 to 2.9.1
Example Code
No response
Python, Pydantic & OS Version
pydantic version: 2.9.1
pydantic-core version: 2.23.3
pydantic-core build: profile=release pgo=false
install path: /Users/kkirsche/Library/Caches/pypoetry/virtualenvs/projectname-g3Hahb8t-py3.12/lib/python3.12/site-packages/pydantic
python version: 3.12.6 (main, Sep 7 2024, 13:48:00) [Clang 15.0.0 (clang-1500.3.9.4)]
platform: macOS-14.6.1-arm64-arm-64bit
related packages: mypy-1.11.2 pydantic-settings-2.5.2 typing_extensions-4.12.2
commit: unknown