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

ACME: improve error handling #49266

Merged
merged 3 commits into from
Nov 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/49266-acme-error-messages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "ACME modules: improve error messages in some cases (include error returned by server)."
6 changes: 4 additions & 2 deletions lib/ansible/module_utils/acme.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ def send_signed_request(self, url, payload, key_data=None, jws_header=None, pars
try:
content = resp.read()
except AttributeError:
content = info.get('body')
content = info.pop('body')

if content or not parse_json_result:
if (parse_json_result and info['content-type'].startswith('application/json')) or 400 <= info['status'] < 600:
Expand All @@ -579,6 +579,8 @@ def send_signed_request(self, url, payload, key_data=None, jws_header=None, pars
continue
if parse_json_result:
result = decoded_result
else:
result = content
except ValueError:
raise ModuleFailException("Failed to parse the ACME response: {0} {1}".format(url, content))
else:
Expand Down Expand Up @@ -608,7 +610,7 @@ def get_request(self, uri, parse_json_result=True, headers=None, get_only=False)
try:
content = resp.read()
except AttributeError:
content = info.get('body')
content = info.pop('body')

# Process result
if parse_json_result:
Expand Down