Skip to content

Commit beb54c9

Browse files
committed
Fix ListProxy handling in _remove_circular_refs
The _remove_circular_refs function in salt.utils.data was trying to reconstruct ListProxy objects by calling type(ob)(), but ListProxy.__init__ requires 3 arguments (target, parent_optsdict, key). When grains data is processed with salt.utils.data.decode(), it calls _remove_circular_refs which failed on ListProxy objects with: TypeError: ListProxy.__init__() missing 2 required positional arguments Fixed by detecting ListProxy and converting to a regular list, consistent with ListProxy.__deepcopy__() and __reduce_ex__() behavior. Fixes: tests/pytests/scenarios/failover/multimaster/test_failover_master.py::test_minion_reconnection
1 parent f327e03 commit beb54c9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

salt/utils/data.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,15 @@ def _remove_circular_refs(ob, _seen=None):
196196
for k, v in ob.items()
197197
}
198198
elif isinstance(ob, (list, tuple, set, frozenset)):
199-
res = type(ob)(_remove_circular_refs(v, _seen) for v in ob)
199+
# Handle ListProxy from OptsDict by converting to regular list
200+
# ListProxy.__init__ requires special arguments, so we can't use type(ob)()
201+
from salt.utils.optsdict import ListProxy
202+
203+
if isinstance(ob, ListProxy):
204+
# Convert ListProxy to regular list (like __deepcopy__ does)
205+
res = list(_remove_circular_refs(v, _seen) for v in ob)
206+
else:
207+
res = type(ob)(_remove_circular_refs(v, _seen) for v in ob)
200208
# remove id again; only *nested* references count
201209
_seen.remove(id(ob))
202210
return res

0 commit comments

Comments
 (0)