From eed2e1d2ac8a3355ba4e0ec0d5a9d7bf8ee81070 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Tue, 2 Jun 2026 21:18:06 +0200 Subject: [PATCH] [PR #12124/b799c6f5 backport][stable-12] redfish_config: fix `KeyError: 'ret'` when `SetManagerNic` cannot find a matching NIC (#12173) redfish_config: fix `KeyError: 'ret'` when `SetManagerNic` cannot find a matching NIC (#12124) * fix(redfish_config): return proper error dict when manager NIC not found get_manager_ethernet_uri() returned an empty dict {} when no matching NIC was found, causing a KeyError on 'ret' in main(). Now returns a consistent {"ret": False, "msg": ...} like all other error paths in the function. Fixes #5892 * feat(changelog): add fragment for PR 12124 (cherry picked from commit b799c6f57916c3b7815d4f2537c941bd3809513a) Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --- changelogs/fragments/12124-redfish-setmanagernic-keyerror.yml | 4 ++++ plugins/module_utils/redfish_utils.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/12124-redfish-setmanagernic-keyerror.yml diff --git a/changelogs/fragments/12124-redfish-setmanagernic-keyerror.yml b/changelogs/fragments/12124-redfish-setmanagernic-keyerror.yml new file mode 100644 index 0000000000..2710cb1b84 --- /dev/null +++ b/changelogs/fragments/12124-redfish-setmanagernic-keyerror.yml @@ -0,0 +1,4 @@ +bugfixes: + - "redfish_config - fix ``KeyError: 'ret'`` when ``SetManagerNic`` cannot find a matching NIC + (https://github.com/ansible-collections/community.general/issues/5892, + https://github.com/ansible-collections/community.general/pull/12124)." diff --git a/plugins/module_utils/redfish_utils.py b/plugins/module_utils/redfish_utils.py index 32033e0df7..46b4923c07 100644 --- a/plugins/module_utils/redfish_utils.py +++ b/plugins/module_utils/redfish_utils.py @@ -3685,7 +3685,7 @@ class RedfishUtils: nic_info["ethernet_setting"] = target_ethernet_current_setting if target_ethernet_uri is None: - return {} + return {"ret": False, "msg": f"Manager NIC with address '{nic_addr}' not found"} else: return nic_info