From 8cefc1bdf8dbae500f4e2fea7565bd79c1544d4b Mon Sep 17 00:00:00 2001 From: goodboy Date: Wed, 15 Apr 2026 18:37:58 -0400 Subject: [PATCH] Guard `brokerd_msg` set in order-mode dialog loop Use `msg.setdefault('brokerd_msg', msg)` instead of blind assignment and log a warning when the field was already populated. Specifically, this avoids a self-reference field recursion which causes crashes when using `tractor.devx.pformat.ppfmt()`.. (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code --- piker/ui/order_mode.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/piker/ui/order_mode.py b/piker/ui/order_mode.py index 7ce39b86..0419a42f 100644 --- a/piker/ui/order_mode.py +++ b/piker/ui/order_mode.py @@ -1022,13 +1022,22 @@ async def open_order_mode( started.set() for oid, msg in ems_dialog_msgs.items(): - # HACK ALERT: ensure a resp field is filled out since # techincally the call below expects a ``Status``. TODO: # parse into proper ``Status`` equivalents ems-side? # msg.setdefault('resp', msg['broker_details']['resp']) # msg.setdefault('oid', msg['broker_details']['oid']) - msg['brokerd_msg'] = msg + ya_msg: dict = msg.setdefault( + 'brokerd_msg', + msg, + ) + if msg is not ya_msg: + log.warning( + f'A `.brokerd_msg` was already set for ems-dialog msg?\n' + f'oid: {oid!r}\n' + f'ya_msg: {ya_msg!r}\n' + f'msg: {ya_msg!r}\n' + ) await process_trade_msg( mode,