From 7139501c162ffaabfee9e1c03b56f9e933758e18 Mon Sep 17 00:00:00 2001 From: Pierre Riteau Date: Wed, 29 Jul 2026 14:02:33 +0200 Subject: [PATCH] Fix error when failing to retrieve inspection rule The error path in case of errors other than HTTP 404 was using an undefined variable. Found by ruff: https://docs.astral.sh/ruff/rules/undefined-name/ Closes-Bug: #2162058 Change-Id: Ie926b531f17fd58ae1297b98118fa66a74a82959 Signed-off-by: Pierre Riteau (cherry picked from commit ce6d4391f42cf3794ad046e1c0e460b64508f1f2) --- .../library/os_ironic_inspector_rule.py | 2 +- releasenotes/notes/bug-2162058-17526c834c348df3.yaml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/bug-2162058-17526c834c348df3.yaml diff --git a/ansible/roles/ironic-inspector-rules/library/os_ironic_inspector_rule.py b/ansible/roles/ironic-inspector-rules/library/os_ironic_inspector_rule.py index c84743a51..896ad793c 100644 --- a/ansible/roles/ironic-inspector-rules/library/os_ironic_inspector_rule.py +++ b/ansible/roles/ironic-inspector-rules/library/os_ironic_inspector_rule.py @@ -88,7 +88,7 @@ def _ensure_rule_present(module, client): if not response.ok: if response.status_code != 404: module.fail_json(msg="Failed retrieving Inspector rule %s: %s" - % (module.params['uuid'], repr(e))) + % (module.params['uuid'], response.text)) else: rule = response.json() # Check whether the rule differs from the request. diff --git a/releasenotes/notes/bug-2162058-17526c834c348df3.yaml b/releasenotes/notes/bug-2162058-17526c834c348df3.yaml new file mode 100644 index 000000000..37d39d83d --- /dev/null +++ b/releasenotes/notes/bug-2162058-17526c834c348df3.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixes displaying the error when a failure to retrieve an inspection rule + occurs. `LP#2162058 `__