RedisStateManager.get_state: return the correct state class#6001
Merged
RedisStateManager.get_state: return the correct state class#6001
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
|
Contributor
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
|
Ensure that fetching a dependency state causes dependent states to also be fetched.
adhami3310
approved these changes
Nov 25, 2025
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.
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.