You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried my Gradio app with the Pydantic 2.11 beta and it crashes on launch. Pydantic 2.11 will be released this month: pydantic/pydantic#11194
It looks to me like this change may have broken the schema parsing in gradio-client: pydantic/pydantic#11392
Schemas now look like this:
{
'description': 'The FileData class is a subclass of the GradioModel class that represents a file object within a Gradio interface. It is used to store file data and metadata when a file is uploaded.\n\nAttributes:\n path: The server file path where the file is stored.\n url: The normalized server URL pointing to the file.\n size: The size of the file in bytes.\n orig_name: The original filename before upload.\n mime_type: The MIME type of the file.\n is_stream: Indicates whether the file is a stream.\n meta: Additional metadata used internally (should not be changed).',
'properties': {
'path': {'title': 'Path', 'type': 'string'},
'url': {'anyOf': [{'type': 'string'}, {'type': 'null'}], 'default': None, 'title': 'Url'},
'size': {'anyOf': [{'type': 'integer'}, {'type': 'null'}], 'default': None, 'title': 'Size'},
'orig_name': {'anyOf': [{'type': 'string'}, {'type': 'null'}], 'default': None, 'title': 'Orig Name'},
'mime_type': {'anyOf': [{'type': 'string'}, {'type': 'null'}], 'default': None, 'title': 'Mime Type'},
'is_stream': {'default': False, 'title': 'Is Stream', 'type': 'boolean'},
'meta': {
# problem seems to be here:'additionalProperties': True,
'default': {'_type': 'gradio.FileData'}, 'title': 'Meta', 'type': 'object'}
},
'required': ['path'],
'title': 'FileData', 'type': 'object'}
}
This means _json_schema_to_python_type(True, ...) is called here, which crashes:
e.g. the "upload_button" example with Pydantic 2.11b1 installed:
importgradioasgrdefupload_file(files):
file_paths= [file.nameforfileinfiles]
returnfile_pathswithgr.Blocks() asdemo:
file_output=gr.File()
upload_button=gr.UploadButton("Click to Upload a File", file_types=["image", "video"], file_count="multiple")
upload_button.upload(upload_file, upload_button, file_output)
demo.launch()
Screenshot
No response
Logs
❯ uv run pydantic_211.py
* Running on local URL: http://127.0.0.1:7861
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
self.scope, self.receive, self.send
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/fastapi/applications.py", line 1054, in __call__
await super().__call__(scope, receive, send)
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/starlette/applications.py", line 112, in __call__
await self.middleware_stack(scope, receive, send)
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/starlette/middleware/errors.py", line 187, in __call__
raise exc
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/starlette/middleware/errors.py", line 165, in __call__
await self.app(scope, receive, _send)
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/gradio/route_utils.py", line 789, in __call__
await self.app(scope, receive, send)
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/starlette/routing.py", line 714, in __call__
await self.middleware_stack(scope, receive, send)
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/starlette/routing.py", line 734, in app
await route.handle(scope, receive, send)
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/starlette/routing.py", line 288, in handle
await self.app(scope, receive, send)
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/starlette/routing.py", line 76, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/starlette/routing.py", line 73, in app
response = await f(request)
^^^^^^^^^^^^^^^^
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/fastapi/routing.py", line 301, in app
raw_response = await run_endpoint_function(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<3 lines>...
)
^
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/fastapi/routing.py", line 214, in run_endpoint_function
return await run_in_threadpool(dependant.call, **values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/starlette/concurrency.py", line 37, in run_in_threadpool
return await anyio.to_thread.run_sync(func)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/anyio/to_thread.py", line 56, in run_sync
return await get_async_backend().run_sync_in_worker_thread(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
func, args, abandon_on_cancel=abandon_on_cancel, limiter=limiter
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 2461, in run_sync_in_worker_thread
return await future
^^^^^^^^^^^^
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 962, in run
result = context.run(func, *args)
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/gradio/routes.py", line 584, in main
gradio_api_info = api_info(request)
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/gradio/routes.py", line 615, in api_info
api_info = utils.safe_deepcopy(app.get_blocks().get_api_info())
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/gradio/blocks.py", line 3015, in get_api_info
python_type = client_utils.json_schema_to_python_type(info)
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/gradio_client/utils.py", line 931, in json_schema_to_python_type
type_ = _json_schema_to_python_type(schema, schema.get("$defs"))
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/gradio_client/utils.py", line 976, in _json_schema_to_python_type
elements = _json_schema_to_python_type(items, defs)
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/gradio_client/utils.py", line 946, in _json_schema_to_python_type
return _json_schema_to_python_type(defs[schema["$ref"].split("/")[-1]], defs)
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/gradio_client/utils.py", line 986, in _json_schema_to_python_type
f"{n}: {_json_schema_to_python_type(v, defs)}{get_desc(v)}"~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/gradio_client/utils.py", line 993, in _json_schema_to_python_type
f"str, {_json_schema_to_python_type(schema['additionalProperties'], defs)}"~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/gradio_client/utils.py", line 939, in _json_schema_to_python_type
type_ = get_type(schema)
File "/Users/max.friedrich/gradio-pydantic-211-repro/.venv/lib/python3.13/site-packages/gradio_client/utils.py", line 898, in get_type
if"const"in schema:
^^^^^^^^^^^^^^^^^
TypeError: argument of type'bool' is not iterable
System Info
Gradio Environment Information:
------------------------------
Operating System: Darwin
gradio version: 5.20.1
gradio_client version: 1.7.2
------------------------------------------------
gradio dependencies in your environment:
aiofiles: 23.2.1
anyio: 4.8.0
audioop-lts: 0.2.1
fastapi: 0.115.11
ffmpy: 0.5.0
gradio-client==1.7.2 is not installed.
groovy: 0.1.2
httpx: 0.28.1
huggingface-hub: 0.29.3
jinja2: 3.1.6
markupsafe: 2.1.5
numpy: 2.2.3
orjson: 3.10.15
packaging: 24.2
pandas: 2.2.3
pillow: 11.1.0
pydantic: 2.11.0b1
pydub: 0.25.1
python-multipart: 0.0.20
pyyaml: 6.0.2
ruff: 0.9.10
safehttpx: 0.1.6
semantic-version: 2.10.0
starlette: 0.46.1
tomlkit: 0.13.2
typer: 0.15.2
typing-extensions: 4.12.2
urllib3: 2.3.0
uvicorn: 0.34.0
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.
gradio_client dependencies in your environment:
fsspec: 2025.3.0
httpx: 0.28.1
huggingface-hub: 0.29.3
packaging: 24.2
typing-extensions: 4.12.2
websockets: 15.0.1
Severity
I can work around it
The text was updated successfully, but these errors were encountered:
Describe the bug
I tried my Gradio app with the Pydantic 2.11 beta and it crashes on launch. Pydantic 2.11 will be released this month: pydantic/pydantic#11194
It looks to me like this change may have broken the schema parsing in gradio-client: pydantic/pydantic#11392
Schemas now look like this:
This means
_json_schema_to_python_type(True, ...)
is called here, which crashes:gradio/client/python/gradio_client/utils.py
Lines 991 to 994 in b3e8c26
Have you searched existing issues? 🔎
Reproduction
e.g. the "upload_button" example with Pydantic 2.11b1 installed:
Screenshot
No response
Logs
System Info
Severity
I can work around it
The text was updated successfully, but these errors were encountered: