-
Notifications
You must be signed in to change notification settings - Fork 671
mixins.py: Avoid sending empty update data to issue.save #389
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
Conversation
When saving an issue we send the updated data only. However the server expect at least one parameter to be provided, otherwise it fails with an exception. Check whether we have some update to send, otherwise skip the update altogether.
gitlab/mixins.py
Outdated
@@ -298,6 +298,9 @@ def save(self, **kwargs): | |||
GitlabUpdateError: If the server cannot perform the request | |||
""" | |||
updated_data = self._get_updated_data() | |||
# Nothing to update. Servers fails if sent an empty dict. | |||
if len(updated_data.keys()) == 9: |
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.
Could you explain the logic here? Where does the 9 come from?
Thanks.
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.
Whops, typo when creating the patch. It should be a 0.
gitlab/mixins.py
Outdated
@@ -298,6 +298,9 @@ def save(self, **kwargs): | |||
GitlabUpdateError: If the server cannot perform the request | |||
""" | |||
updated_data = self._get_updated_data() | |||
# Nothing to update. Server fails if sent an empty dict. | |||
if len(updated_data.keys()) == 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.
Thanks for the update!
A more pythonic way to write this would be:
if not update_data:
return
Could you update the code? Thanks again.
Thanks for the review, I didn't know en empty dictionary works with the "not". |
Thanks @csoriano1618 👍 |
python-gitlab/python-gitlab#389 means that python-gitlab will raise an exception if save() is called with no parameters. This sends a redundant parameter as a workaround.
When saving an issue we send the updated data only.
However the server expect at least one parameter to be provided,
otherwise it fails with an exception.
Check whether we have some update to send, otherwise skip
the update altogether.