-
Notifications
You must be signed in to change notification settings - Fork 1.7k
RedisStateManager.get_state: return the correct state class #6001
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Save the originally requested state class as `requested_state_cls` so a subsequent loop variable that was also called `state_cls` doesn't interfere with returning the correct state at the end of the function.
CodSpeed Performance ReportMerging #6001 will not alter performanceComparing Summary
|
Greptile OverviewGreptile SummaryFixed a critical variable shadowing bug in
Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Client
participant StateManagerRedis
participant Redis
participant StateTree
Client->>StateManagerRedis: get_state(token)
Note over StateManagerRedis: Split token to extract state_path
StateManagerRedis->>StateManagerRedis: requested_state_cls = get_class_substate(state_path)
Note over StateManagerRedis: Store requested class before loop
StateManagerRedis->>StateManagerRedis: Get already populated states
StateManagerRedis->>StateManagerRedis: Calculate required_state_classes
loop For each required state class
StateManagerRedis->>Redis: pipeline.get(_substate_key(token, state_cls))
end
Redis-->>StateManagerRedis: Return redis_state data
loop For each state_cls in required_state_classes
Note over StateManagerRedis: Loop variable state_cls does NOT overwrite requested_state_cls
StateManagerRedis->>StateManagerRedis: Deserialize or create state instance
StateManagerRedis->>StateTree: Add state to flat_state_tree
StateManagerRedis->>StateTree: Link parent-child relationships
end
alt top_level requested
StateManagerRedis-->>Client: Return top-level state
else specific substate requested
Note over StateManagerRedis: Return requested_state_cls, not last loop iteration
StateManagerRedis-->>Client: Return flat_state_tree[requested_state_cls.get_full_name()]
end
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 files reviewed, no comments
Ensure that fetching a dependency state causes dependent states to also be fetched.
Save the originally requested state class as
requested_state_clsso a subsequent loop variable that was also calledstate_clsdoesn't interfere with returning the correct state at the end of the function.