mixins.py: Avoid sending empty update data to issue.save#389
Merged
gpocentek merged 4 commits intopython-gitlab:masterfrom Dec 16, 2017
Merged
mixins.py: Avoid sending empty update data to issue.save#389gpocentek merged 4 commits intopython-gitlab:masterfrom
gpocentek merged 4 commits intopython-gitlab:masterfrom
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.
gpocentek
reviewed
Dec 11, 2017
gitlab/mixins.py
Outdated
| """ | ||
| updated_data = self._get_updated_data() | ||
| # Nothing to update. Servers fails if sent an empty dict. | ||
| if len(updated_data.keys()) == 9: |
Contributor
There was a problem hiding this comment.
Could you explain the logic here? Where does the 9 come from?
Thanks.
Contributor
Author
There was a problem hiding this comment.
Whops, typo when creating the patch. It should be a 0.
gpocentek
reviewed
Dec 13, 2017
gitlab/mixins.py
Outdated
| """ | ||
| updated_data = self._get_updated_data() | ||
| # Nothing to update. Server fails if sent an empty dict. | ||
| if len(updated_data.keys()) == 0: |
Contributor
There was a problem hiding this comment.
Thanks for the update!
A more pythonic way to write this would be:
if not update_data:
returnCould you update the code? Thanks again.
Contributor
Author
|
Thanks for the review, I didn't know en empty dictionary works with the "not". |
Contributor
|
Thanks @csoriano1618 👍 |
zmike
pushed a commit
to zmike/bztogl
that referenced
this pull request
Jul 5, 2019
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.