test_state_schema_optional_values throws PydanticForbiddenQualifier with latest Pydantic (2.11.1) #594

Closed
opened 2026-02-20 17:40:52 -05:00 by yindo · 3 comments
Owner

Originally created by @sarahec on GitHub (Apr 21, 2025).

Originally assigned to: @sydney-runkle on GitHub.

Checked other resources

  • This is a bug, not a usage question. For questions, please use GitHub Discussions.
  • I added a clear and detailed title that summarizes the issue.
  • I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example).
  • I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue.

Example Code

# N/A, this is a build error

Error Message and Stack Trace (if applicable)

> FAILED tests/test_state.py::test_state_schema_optional_values[False] - pydantic.errors.PydanticForbiddenQualifier: The annotation 'Required[str]' ...
       > FAILED tests/test_state.py::test_state_schema_optional_values[True] - pydantic.errors.PydanticForbiddenQualifier: The annotation 'Required[str]' ...


in [`test_state.py`:133-152](https://github.com/langchain-ai/langgraph/blob/c7306f7aed68334a4287b4eed9c05444e4b095a6/libs/langgraph/tests/test_state.py#L133-L152)

Description

While building langgraph for nixpkgs, the following error appears:

       > FAILED tests/test_state.py::test_state_schema_optional_values[False] -  pydantic.errors.PydanticForbiddenQualifier: The annotation 'Required[str]' contains the 'typing.Required' type qualifier, which is invalid in the context it is defined.
       > FAILED tests/test_state.py::test_state_schema_optional_values[True] - pydantic.errors.PydanticForbiddenQualifier: The annotation 'Required[str]' contains the 'typing.Required' type qualifier, which is invalid in the context it is defined.

Probable cause

The affected test code is > 6 months old, so I looked at the dependencies.

nixpkgs is currently on pydantic 2.11.1 and pydantic-core 2.33.0.

poetry.lock uses an older pydantic:

[[package]]
name = "pydantic"
version = "2.9.2"
description = "Data validation using Python type hints"
optional = false
python-versions = ">=3.8"
groups = ["main", "dev"]
files = [
    {file = "pydantic-2.9.2-py3-none-any.whl", hash = "sha256:f048cec7b26778210e28a0459867920654d48e5e62db0958433636cde4254f12"},
    {file = "pydantic-2.9.2.tar.gz", hash = "sha256:d155cef71265d1e9807ed1c32b4c8deec042a44a50a4188b25ac67ecd81a9c0f"},
]


[package.dependencies]
annotated-types = ">=0.6.0"
pydantic-core = "2.23.4"
typing-extensions = [
    {version = ">=4.6.1", markers = "python_version < \"3.13\""},
    {version = ">=4.12.2", markers = "python_version >= \"3.13\""},
]

System Info

n/a

Originally created by @sarahec on GitHub (Apr 21, 2025). Originally assigned to: @sydney-runkle on GitHub. ### Checked other resources - [x] This is a bug, not a usage question. For questions, please use GitHub Discussions. - [x] I added a clear and detailed title that summarizes the issue. - [x] I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example). - [x] I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue. ### Example Code ```python # N/A, this is a build error ``` ### Error Message and Stack Trace (if applicable) ```shell > FAILED tests/test_state.py::test_state_schema_optional_values[False] - pydantic.errors.PydanticForbiddenQualifier: The annotation 'Required[str]' ... > FAILED tests/test_state.py::test_state_schema_optional_values[True] - pydantic.errors.PydanticForbiddenQualifier: The annotation 'Required[str]' ... in [`test_state.py`:133-152](https://github.com/langchain-ai/langgraph/blob/c7306f7aed68334a4287b4eed9c05444e4b095a6/libs/langgraph/tests/test_state.py#L133-L152) ``` ### Description While building `langgraph` for nixpkgs, the following error appears: ```sh > FAILED tests/test_state.py::test_state_schema_optional_values[False] - pydantic.errors.PydanticForbiddenQualifier: The annotation 'Required[str]' contains the 'typing.Required' type qualifier, which is invalid in the context it is defined. > FAILED tests/test_state.py::test_state_schema_optional_values[True] - pydantic.errors.PydanticForbiddenQualifier: The annotation 'Required[str]' contains the 'typing.Required' type qualifier, which is invalid in the context it is defined. ``` ### Probable cause The affected test code is > 6 months old, so I looked at the dependencies. nixpkgs is currently on [`pydantic`](https://search.nixos.org/packages?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=pydantic) 2.11.1 and [`pydantic-core`](https://search.nixos.org/packages?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=pydantic-core) 2.33.0. `poetry.lock` uses an older pydantic: ```toml [[package]] name = "pydantic" version = "2.9.2" description = "Data validation using Python type hints" optional = false python-versions = ">=3.8" groups = ["main", "dev"] files = [ {file = "pydantic-2.9.2-py3-none-any.whl", hash = "sha256:f048cec7b26778210e28a0459867920654d48e5e62db0958433636cde4254f12"}, {file = "pydantic-2.9.2.tar.gz", hash = "sha256:d155cef71265d1e9807ed1c32b4c8deec042a44a50a4188b25ac67ecd81a9c0f"}, ] [package.dependencies] annotated-types = ">=0.6.0" pydantic-core = "2.23.4" typing-extensions = [ {version = ">=4.6.1", markers = "python_version < \"3.13\""}, {version = ">=4.12.2", markers = "python_version >= \"3.13\""}, ] ``` ### System Info n/a
yindo added the bughelp wanteddependenciestests labels 2026-02-20 17:40:52 -05:00
yindo closed this issue 2026-02-20 17:40:52 -05:00
Author
Owner

@sydney-runkle commented on GitHub (May 28, 2025):

Confirmed this is an issue with our tests

@sydney-runkle commented on GitHub (May 28, 2025): Confirmed this is an issue with our tests
Author
Owner

@sarahec commented on GitHub (May 28, 2025):

@sydney-runkle thank you :)

@sarahec commented on GitHub (May 28, 2025): @sydney-runkle thank you :)
Author
Owner

@sydney-runkle commented on GitHub (Jun 11, 2025):

Good first issue - help us upgrade to Pydantic v2.11 in our tests :)

@sydney-runkle commented on GitHub (Jun 11, 2025): Good first issue - help us upgrade to Pydantic v2.11 in our tests :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#594