fix(tree): guard updateTreeData against null list - #2423
Merged
openai0229 merged 3 commits intoAug 3, 2026
Merged
Conversation
updateTreeData did list.map(...) with no null guard. getTreeData/clearTreeStore null out treeData, and handleLoadData passes the (possibly null) origin into setTreeData, so a refresh racing a lazy-load threw null.map and crashed the tree view. Guard with Array.isArray and return []. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: liuhy <liuhongyu@apache.org>
There was a problem hiding this comment.
Pull request overview
This PR addresses a crash in the community client tree store where updateTreeData could throw null.map during a refresh/lazy-load race, taking down the tree view.
Changes:
- Added a runtime guard in
updateTreeDatato avoid calling.map()on a null/invalid list. - Documented the race scenario inline to explain why the guard is necessary.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
# Conflicts: # chat2db-community-client/package.json
openai0229
approved these changes
Aug 3, 2026
openai0229
left a comment
Contributor
There was a problem hiding this comment.
Reviewed after merging the latest main and fixing the loading-state regression. Null is preserved, nested updates remain immutable, focused regression tests pass, targeted ESLint passes, and the test is part of the Community prebuild.
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.
What
A tree refresh can set treeData to null while a previously-started lazy load settles. updateTreeData previously dereferenced the null value and crashed the tree view.
Fix
Verification
Fixes #2422