-
Notifications
You must be signed in to change notification settings - Fork 40
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
add msg if API response can't be converted #486
Conversation
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
Thank you for raising PR |
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
Added a |
Is that problem is resolved?? |
Not yet @marathe-99, this will go in next maintenance release. |
plugins/module_utils/entity.py
Outdated
resp_json_msg = "{0}".format(info.get("msg")) | ||
else: | ||
try: | ||
if len(info.get("msg")) > 2: |
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.
Thats fine, let it be 0 so that we can back trace any error message in our product code base.
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.
done
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.
@konstruktoid What happens if msg key is not present in info ? I am just thinking it can cause TypeError ? As len(None) can cause that. Does ansible's fetch_url confirms that msg will be always a string ?
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.
Since you are only checking ValueError.
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.
yeah, perhaps i should just simplify it like https://github.com/nutanix/nutanix.ansible/pull/486/files#diff-be0a07cfc89126d4e28a8fbd2d2716635f9ab383eb08f54b504429dd647853efL399-L400
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.
@konstruktoid there is a small syntax issue. Please check latest comment
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
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.
LGTM
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.
LGTM
This PR makes the return msg a bit more helpful when the API response can't be converted to json.
Pre- and post-patch: