From bfefee5aef0667e4640c2cee93bef7c28e7823f0 Mon Sep 17 00:00:00 2001 From: Ben Thomasson Date: Wed, 18 Mar 2026 13:17:25 -0400 Subject: [PATCH] fix: NameError in wsrelay when JSON decode fails with DEBUG logging (#16340) * fix: NameError in wsrelay when JSON decode fails with DEBUG logging run_connection() referenced payload in the JSONDecodeError handler, but payload was never assigned because json.loads() is what failed. Use msg.data instead to log the raw message content. Fixes: AAP-68045 Co-Authored-By: Claude Opus 4.6 * Fix other instance of undefined payload --------- Co-authored-by: Claude Opus 4.6 Co-authored-by: AlanCoding --- awx/main/wsrelay.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/awx/main/wsrelay.py b/awx/main/wsrelay.py index 9e55e3e2c8..d13ff13671 100644 --- a/awx/main/wsrelay.py +++ b/awx/main/wsrelay.py @@ -139,7 +139,7 @@ class WebsocketRelayConnection: except json.JSONDecodeError: logmsg = "Failed to decode message from web node" if logger.isEnabledFor(logging.DEBUG): - logmsg = "{} {}".format(logmsg, payload) + logmsg = "{} {}".format(logmsg, msg.data) logger.warning(logmsg) continue @@ -242,7 +242,7 @@ class WebSocketRelayManager(object): except json.JSONDecodeError: logmsg = "Failed to decode message from pg_notify channel `web_ws_heartbeat`" if logger.isEnabledFor(logging.DEBUG): - logmsg = "{} {}".format(logmsg, payload) + logmsg = "{} {}".format(logmsg, notif.payload) logger.warning(logmsg) continue