Description
Tree store actions (deleteAiDataCollection, deleteAiDataCollectionElement, updateTreeNodeDataByKey, closeConnection, updateOriginalTitleByNodeId, getChildrenByNodeId) pass get().treeData! into findNode/getParentNode. treeData is legitimately null (initial value, getTreeData, clearTreeStore null it). findNode/getParentNode dereference tree.length with no null guard → null.length NPE. The ! non-null assertions at call sites mask the nullable type.
Location
chat2db-community-client/src/utils/index.ts:384-397 (getParentNode), :425-438 (findNode); call sites src/store/tree/index.tsx:501,526,568,655,669,678.
Impact
Rename/delete/close-connection actions NPE when treeData is null (e.g. right after login or during a refresh).
Suggested fix
Make findNode/getParentNode null-tolerant (guard if (!tree || !tree.length) return undefined; and drop the ! on the return), so a null tree yields undefined instead of throwing. Single-point fix covering all call sites.
Related existing
None.
Description
Tree store actions (
deleteAiDataCollection,deleteAiDataCollectionElement,updateTreeNodeDataByKey,closeConnection,updateOriginalTitleByNodeId,getChildrenByNodeId) passget().treeData!intofindNode/getParentNode.treeDatais legitimatelynull(initial value,getTreeData,clearTreeStorenull it).findNode/getParentNodedereferencetree.lengthwith no null guard →null.lengthNPE. The!non-null assertions at call sites mask the nullable type.Location
chat2db-community-client/src/utils/index.ts:384-397(getParentNode),:425-438(findNode); call sitessrc/store/tree/index.tsx:501,526,568,655,669,678.Impact
Rename/delete/close-connection actions NPE when
treeDatais null (e.g. right after login or during a refresh).Suggested fix
Make
findNode/getParentNodenull-tolerant (guardif (!tree || !tree.length) return undefined;and drop the!on the return), so a null tree yieldsundefinedinstead of throwing. Single-point fix covering all call sites.Related existing
None.