From 67388be1a9299401b2e1369f82da2751c67e8ad4 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Fri, 17 Dec 2021 22:13:43 +0100 Subject: [PATCH] jira - fixed 'body' dict key error (#3867) (#3914) * fixed * added changelog fragment * improved fail output when placing JIRA API requests * Update plugins/modules/web_infrastructure/jira.py Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein (cherry picked from commit e6c773a4f3de03675eb675be3044f471c56c24ea) Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --- changelogs/fragments/3867-jira-fix-body.yaml | 2 ++ plugins/modules/web_infrastructure/jira.py | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/3867-jira-fix-body.yaml diff --git a/changelogs/fragments/3867-jira-fix-body.yaml b/changelogs/fragments/3867-jira-fix-body.yaml new file mode 100644 index 0000000000..0edb395e70 --- /dev/null +++ b/changelogs/fragments/3867-jira-fix-body.yaml @@ -0,0 +1,2 @@ +bugfixes: + - jira - fixed bug where module returns error related to dictionary key ``body`` (https://github.com/ansible-collections/community.general/issues/3419). diff --git a/plugins/modules/web_infrastructure/jira.py b/plugins/modules/web_infrastructure/jira.py index 942a804556..676b4620d2 100644 --- a/plugins/modules/web_infrastructure/jira.py +++ b/plugins/modules/web_infrastructure/jira.py @@ -694,7 +694,14 @@ class JIRA(StateModuleHelper): try: error = json.loads(info['body']) except Exception: - self.module.fail_json(msg=to_native(info['body']), exception=traceback.format_exc()) + msg = 'The request "{method} {url}" returned the unexpected status code {status} {msg}\n{body}'.format( + status=info['status'], + msg=info['msg'], + body=info.get('body'), + url=url, + method=method, + ) + self.module.fail_json(msg=to_native(msg), exception=traceback.format_exc()) if error: msg = [] for key in ('errorMessages', 'errors'):