Skip to content

Commit

Permalink
Allow type to be missing. (#652)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Aug 21, 2023
1 parent 5d2bfdd commit 526b3c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/652-problem-type.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "acme_* modules - correctly handle error documents without ``type`` (https://github.com/ansible-collections/community.crypto/issues/651, https://github.com/ansible-collections/community.crypto/pull/652)."
5 changes: 3 additions & 2 deletions plugins/module_utils/acme/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ def format_http_status(status_code):


def format_error_problem(problem, subproblem_prefix=''):
error_type = problem.get('type', 'about:blank') # https://www.rfc-editor.org/rfc/rfc7807#section-3.1
if 'title' in problem:
msg = 'Error "{title}" ({type})'.format(
type=problem['type'],
type=error_type,
title=problem['title'],
)
else:
msg = 'Error {type}'.format(type=problem['type'])
msg = 'Error {type}'.format(type=error_type)
if 'detail' in problem:
msg += ': "{detail}"'.format(detail=problem['detail'])
subproblems = problem.get('subproblems')
Expand Down

0 comments on commit 526b3c4

Please sign in to comment.