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 <noreply@anthropic.com>

* Fix other instance of undefined payload

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: AlanCoding <arominge@redhat.com>
This commit is contained in:
Ben Thomasson
2026-03-18 13:17:25 -04:00
committed by GitHub
parent 0aaca1bffd
commit bfefee5aef

View File

@@ -139,7 +139,7 @@ class WebsocketRelayConnection:
except json.JSONDecodeError: except json.JSONDecodeError:
logmsg = "Failed to decode message from web node" logmsg = "Failed to decode message from web node"
if logger.isEnabledFor(logging.DEBUG): if logger.isEnabledFor(logging.DEBUG):
logmsg = "{} {}".format(logmsg, payload) logmsg = "{} {}".format(logmsg, msg.data)
logger.warning(logmsg) logger.warning(logmsg)
continue continue
@@ -242,7 +242,7 @@ class WebSocketRelayManager(object):
except json.JSONDecodeError: except json.JSONDecodeError:
logmsg = "Failed to decode message from pg_notify channel `web_ws_heartbeat`" logmsg = "Failed to decode message from pg_notify channel `web_ws_heartbeat`"
if logger.isEnabledFor(logging.DEBUG): if logger.isEnabledFor(logging.DEBUG):
logmsg = "{} {}".format(logmsg, payload) logmsg = "{} {}".format(logmsg, notif.payload)
logger.warning(logmsg) logger.warning(logmsg)
continue continue