Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make exceptions in the Client more specific #8264

Merged
merged 6 commits into from May 13, 2024
Merged

Conversation

abidlabs
Copy link
Member

@abidlabs abidlabs commented May 11, 2024

Previously, If an exception was raised in the upstream app due to an invalid value provided by the Python Client, then the error that is raised is not very informative:

ValueError: None

My initial thought was to transmit the error from the server to the client to provide better error messages. However, we intentionally do not reveal exceptions to users of Gradio applications as they can reveal security vulnerabilities, unless show_error=True.

So this PR only prints the upstream exception if show_error=True, otherwise prints a generic error explaining how to print more detailed errors. For other types of errors that the Client can generate, e.g. when an invalid parameter is provided, it changes the errors to be TypeError instead of ValueError -- that's consistent with the error type that is raised when you call a function in Python with the wrong parameters.

Closes: #7889

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented May 11, 2024

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
🦄 Changes detecting...

Install Gradio from this PR

pip install https://gradio-builds.s3.amazonaws.com/8d91c14aa50754fca4fceb1f8f9582923a3523f0/gradio-4.31.0-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@8d91c14aa50754fca4fceb1f8f9582923a3523f0#subdirectory=client/python"

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented May 11, 2024

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
gradio patch
gradio_client patch
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Make exceptions in the Client more specific

Maintainers or the PR author can modify the PR title to modify this entry.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@abidlabs abidlabs marked this pull request as ready for review May 12, 2024 02:58
@@ -0,0 +1,6 @@
---
"gradio": minor
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: feels like a patch to me

Copy link
Collaborator

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely @abidlabs !

@abidlabs abidlabs added the v: patch A change that requires a patch release label May 13, 2024
@abidlabs
Copy link
Member Author

Thanks @freddyaboulton for the review!

@abidlabs abidlabs merged commit a9e1a8a into main May 13, 2024
7 checks passed
@abidlabs abidlabs deleted the specific-exceptions branch May 13, 2024 19:06
@pngwn pngwn mentioned this pull request May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v: patch A change that requires a patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better error messages with the Python Client
3 participants