fix: add missing list/dict methods to LockedListProxy and LockedDictProxy#4760
Open
lucasgomide wants to merge 1 commit intomainfrom
Open
fix: add missing list/dict methods to LockedListProxy and LockedDictProxy#4760lucasgomide wants to merge 1 commit intomainfrom
lucasgomide wants to merge 1 commit intomainfrom
Conversation
2b78458 to
4789721
Compare
…roxy LockedListProxy and LockedDictProxy subclass `list` and `dict` but initialize the parent as empty (`super().__init__()`), delegating all access to an internal `self._list` / `self._dict`. However, several inherited methods were not overridden, causing them to silently operate on the empty parent instead of the real data. Most critically, `list.index()` always raises `ValueError` because it searches the empty parent list. Other broken methods include `count()` (always returns 0), `sort()`/`reverse()` (no-ops), `copy()` (returns empty), and arithmetic operators (`+`, `*`). All mutating operations acquire the lock; read-only operations delegate directly to the underlying collection, consistent with existing pattern.
4789721 to
497400f
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| def __iadd__(self, other: Iterable[T]) -> list[T]: | ||
| with self._lock: | ||
| self._list += list(other) | ||
| return self._list |
There was a problem hiding this comment.
In-place operators return raw collection, breaking proxy identity
Medium Severity
__iadd__, __imul__, and __ior__ return the raw internal self._list/self._dict instead of self. After augmented assignment on a proxy reference (e.g., items = flow.state.items; items += [10]), the variable silently becomes a plain list/dict, losing all thread-safety guarantees from the lock. The primary flow.state.items += [10] path works only because StateProxy re-wraps on every access, but direct proxy holders lose protection.
Additional Locations (2)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


We introduced a breaking change in 1.10.x when a Flow tries to access its state using .index (for example)
LockedListProxy and LockedDictProxy subclass
listanddictbut initialize the parent as empty (super().__init__()), delegating all access to an internalself._list/self._dict. However, several inherited methods were not overridden, causing them to silently operate on the empty parent instead of the real data.Most critically,
list.index()always raisesValueErrorbecause it searches the empty parent list. Other broken methods includecount()(always returns 0),sort()/reverse()(no-ops),copy()(returns empty), and arithmetic operators (+,*).All mutating operations acquire the lock; read-only operations delegate directly to the underlying collection, consistent with existing pattern.
Note
Medium Risk
Touches core flow state proxy behavior and locking for common container operations, which could subtly affect concurrency or operator semantics. Changes are narrowly scoped and covered by new unit tests for the previously broken methods.
Overview
Fixes broken container behavior in flow state proxies.
LockedListProxyandLockedDictProxynow override additional list/dict methods and operators (e.g.index,count,sort/reverse,copy,+/*, and dict union|/|=) so they delegate to the underlyingself._list/self._dictinstead of the empty parent container.Adds regression coverage. New tests in
test_flow.pyvalidate the corrected behavior (including in-place mutation operators not deadlocking and non-mutating operators returning new containers).Written by Cursor Bugbot for commit 497400f. This will update automatically on new commits. Configure here.