-
Notifications
You must be signed in to change notification settings - Fork 632
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add a helpful errorwhen commit_message is empty in create_commit #962
Conversation
Out of curiosity, do you have a copy of the obscure server error you got? |
The documentation is not available anymore as the PR was closed or merged. |
@osanseviero Here you go (just ignore the top level of the traceback which is from Transformers):
|
could also be solved with a better error from server (cc @SBrandeis) |
Works for me too! |
The server already returns an error message in the HTTP response: {"error": "\"summary\" is not allowed to be empty"} But it's not obvious to match |
@@ -1858,6 +1858,8 @@ def create_commit( | |||
If `create_pr` is `True`, returns the URL to the newly created Pull Request | |||
on the Hub. Otherwise returns `None`. | |||
""" | |||
if commit_message is None or len(commit_message) == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if commit_message is None or len(commit_message) == 0: | |
if not commit_message: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have been burned too many times by relying on Python bool-conversion magic so I prefer explicit tests :-) But feel free to merge the suggestion if it fits the style of huggingface_hub better.
If you call
create_commit
with an emptycommit_message
(either None or""
) you will get an obscure error from the server. This PR catches it earlier to send a more informative error message.