From 7bb23e9649516a9c26c8bd01bacda2ad67d6d912 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Mon, 31 Jul 2023 15:44:57 +0200 Subject: [PATCH] [PR #6983/a942545d backport][stable-6] Rundeck - fix TypeError on 404 api response (#7040) Rundeck - fix TypeError on 404 api response (#6983) * fix TypeError on 404 api response * add changelog fragment * Update changelogs/fragments/6983-rundeck-fix-typerrror-on-404-api-response.yml Co-authored-by: Felix Fontein --------- Co-authored-by: Vincent CHARLES Co-authored-by: Felix Fontein (cherry picked from commit a942545dd2ec718993f95db35ac3e988d24e73a5) Co-authored-by: Vincent CHARLES <124702855+MehuiSeklayr@users.noreply.github.com> --- .../6983-rundeck-fix-typerrror-on-404-api-response.yml | 2 ++ plugins/module_utils/rundeck.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/6983-rundeck-fix-typerrror-on-404-api-response.yml diff --git a/changelogs/fragments/6983-rundeck-fix-typerrror-on-404-api-response.yml b/changelogs/fragments/6983-rundeck-fix-typerrror-on-404-api-response.yml new file mode 100644 index 0000000000..a530533a2f --- /dev/null +++ b/changelogs/fragments/6983-rundeck-fix-typerrror-on-404-api-response.yml @@ -0,0 +1,2 @@ +bugfixes: + - rundeck - fix ``TypeError`` on 404 API response (https://github.com/ansible-collections/community.general/pull/6983). diff --git a/plugins/module_utils/rundeck.py b/plugins/module_utils/rundeck.py index 6fb56fbaea..7df68a3603 100644 --- a/plugins/module_utils/rundeck.py +++ b/plugins/module_utils/rundeck.py @@ -72,7 +72,9 @@ def api_request(module, endpoint, data=None, method="GET"): if info["status"] == 403: module.fail_json(msg="Token authorization failed", execution_info=json.loads(info["body"])) - if info["status"] == 409: + elif info["status"] == 404: + return None, info + elif info["status"] == 409: module.fail_json(msg="Job executions limit reached", execution_info=json.loads(info["body"])) elif info["status"] >= 500: