gradio icon indicating copy to clipboard operation
gradio copied to clipboard

raising `gr.Error` gives "Unexpected end of JSON input" in Colab notebooks

Open anentropic opened this issue 1 year ago • 21 comments

Describe the bug

raising the error is supposed to show a modal with the custom error message

instead the error modal says "Unexpected end of JSON input"

Is there an existing issue for this?

  • [X] I have searched the existing issues

Reproduction

import gradio as gr

def welcome(name):
    if name == "WTF":
      raise gr.Error("It doesn't work")
    return f"Welcome to Gradio, {name}!"

with gr.Blocks() as demo:
    gr.Markdown(
    """
    # Hello World!
    Start typing below to see the output.
    """)
    inp = gr.Textbox(placeholder="What is your name?")
    out = gr.Textbox()
    inp.submit(welcome, inp, out)

if __name__ == "__main__":
    demo.launch()

Screenshot

Screenshot 2023-04-17 at 11 41 08

Logs

n/a

System Info

Gradio: 3.27.0
Google Colab ipynb

Severity

annoying

anentropic avatar Apr 17 '23 10:04 anentropic

I get the same thing if I raise ValueError instead of gr.Error

the docs example for gr.Error uses an Interface instead of Blocks... is this not supported in Blocks?

anentropic avatar Apr 17 '23 10:04 anentropic

Hi @anentropic !

gr.Error works with blocks. I can only reproduce your error in colab, not locally. And setting a share link via share=True removes the error.

image

Makes me think it is a colab-specific bug. We will look into it!

freddyaboulton avatar Apr 17 '23 14:04 freddyaboulton

how should I fix this

niyasj avatar Apr 21 '23 04:04 niyasj

I'm not sure what the underlying cause is yet. Seems to be an issue in colab? I would set share=True since that is a workaround for now.

freddyaboulton avatar Apr 21 '23 16:04 freddyaboulton

hi! seems that i found root cause for this issue, google colab proxy does not pass data for responses with 4xx / 5xx codes (more context here https://github.com/googlecolab/colabtools/issues/3308). it just returns 505 html page not json data of error.

here is example 2023-04-24_15-11.

not sure however how to fix it

tye-singwa avatar Apr 24 '23 12:04 tye-singwa

Thank you for looking into this @tye-singwa ! Now that we know the likely root cause, we can ask colab support. I can take care of that.

freddyaboulton avatar Apr 24 '23 14:04 freddyaboulton

Let's sit tight. Colab is working on a fix for this on their end.

freddyaboulton avatar Apr 25 '23 15:04 freddyaboulton

Is it fixed by Colab?

Rushikesh1234 avatar May 05 '23 20:05 Rushikesh1234

Not yet as far as I know

abidlabs avatar May 05 '23 21:05 abidlabs

Having the same issue

mashdud avatar May 06 '23 12:05 mashdud

I'm also facing the same issue with google colab

agkush avatar Jun 26 '23 12:06 agkush

iam also facing the same issue with gradio

Viveklagishetty avatar Jul 30 '23 10:07 Viveklagishetty

issue cleared we have to signup with new email id which you have not used before in chatgpt then after we have to create api

Viveklagishetty avatar Jul 30 '23 12:07 Viveklagishetty

Issue Resolved : step : To view errors and logs, set debug=True in launch() ~ You find error and try to slove it ~ error's like Incorrect API key. ~Expiration of credit score in OpenAi If still not resolved, after above steps , set share=True in launch()

chakrateja70 avatar Jul 30 '23 16:07 chakrateja70

issue cleared we have to signup with new email id which you have not used before in chatgpt then after we have to create api

will you please elaborate the process I an not able to do it

agkush avatar Jul 31 '23 07:07 agkush

I'm also facing the same issue with google colab, How to fix it?

samPuriwat avatar Aug 03 '23 05:08 samPuriwat

Thanks @chakrateja70 debug = True worked... In my case the issue was in the function.

mahajandeepakshi03 avatar Aug 05 '23 02:08 mahajandeepakshi03

I'm also facing the same issue with google colab, How to fix it?

Check my comment above maybe it's helpful

chakrateja70 avatar Aug 05 '23 05:08 chakrateja70

Hi all, sorry the problem is with Google colab. I will follow up with them to see if they have a fix coming soon. I think setting share=True and clicking on the share link should make this go away.

freddyaboulton avatar Aug 05 '23 15:08 freddyaboulton

Hi @freddyaboulton I'm also facing the same issue with Google Colab. Your last solution not working for me.

PooryaASG avatar Oct 07 '23 22:10 PooryaASG

the problem is still...

beatG123 avatar Apr 16 '24 08:04 beatG123