Gradio problem, gradio change not functioning good for gr.Image

:red_exclamation_mark: FastAPI / Gradio Error: TypeError: argument of type 'bool' is not iterable

I’m running into an error when using Gradio (wrapped in FastAPI, served with uvicorn). When a frontend interaction is triggered, I get the following traceback (excerpt):

TypeError: argument of type 'bool' is not iterable
File "gradio_client\utils.py", line 898, in get_type
  if "const" in schema:

:magnifying_glass_tilted_left: Context:

Here’s the code that causes the error:

im_display.change(fn=update_image, inputs=[im_display], outputs=[s3image])
  • im_display is a gr.Image()
  • s3image is also a gr.Image()
  • The function update_image returns gr.update(...)

:warning: If I change the output to a gr.Textbox(), like this:

im_display.change(fn=update_image, inputs=[im_display], outputs=[gr.Textbox()])

Then the error does not happen. So the issue seems to be related to using gr.Image as the output.

:repeat_button: Additional Info:

  • The error still happens no matter what arguments I pass to gr.update(), e.g., value=..., visible=True, etc.
  • Everything works fine when returning updates to a Textbox.

:red_question_mark: Question:

Has anyone else run into this issue when returning gr.update() to a gr.Image() output?
Is there a workaround or fix for this schema parsing issue?

My environment:

  • Windows / Conda
  • Python 3.x
  • Gradio installed via pip (5.20)

Any help is appreciated! I can provide a minimal reproducible example if needed.

1 Like

TypeError: argument of type ‘bool’ is not iterable
File “gradio_client\utils.py”, line 898, in get_type
if “const” in schema:

The conditions and components are completely different, but the error content is exactly the same, so it might be the same cause…

pydantic==2.10.6
1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.