Cannot read properties of null (reading 'get') in eager-loading-tree.js during BelongsToMany association loading

                                                                                                                                                                             **Environment:**                                                                                                                                                                                                                                             

• NocoBase Version: 2.0.0-beta.1-full (Also reproduced in alpha.59)
• Database: PostgreSQL 16
• Deployment: Docker (Full image)
• Node.js Version: v20.19.6
Description:
After upgrading to version 2.0-beta, a TableBlockModel using a Tree collection (projects) and a specific dataScope filter failed with a 500 error. The server logs pointed to a null pointer exception in the database engine’s eager loading logic.

Error Trace:
TypeError: Cannot read properties of null (reading ‘get’)
at /app/nocobase/node_modules/@nocobase/database/lib/eager-loading/eager-loading-tree.js:445:94
at Array.find (#### Anonymous
)
at loadRecursive (/app/nocobase/node_modules/@nocobase/database/lib/eager-loading/eager-loading-tree.js:444:58)

Root Cause:
In BelongsToMany association type handling, the code assumes instance.dataValues[as] is always defined before calling .get(foreignKey). In certain complex tree queries or when the association data is empty/null, this causes the application to crash.

Reproduction:
• Create a collection with Tree structure.
• Add a BelongsToMany association (e.g., participants).
• Create a Table block with “Enable Tree Table” and a dataScope filter that includes the association (e.g., participants.username $includes …).
• Access the page.

Suggested Fix (Hotfix applied):
Added optional chaining to safely access the pivot data.
File: node_modules/@nocobase/database/src/eager-loading/eager-loading-tree.ts (or .js in dist)
// From:
(parentInstance2) => parentInstance2.get(sourceKey) == instance.dataValues[as].get(foreignKey)

// To:
(parentInstance2) => parentInstance2.get(sourceKey) == instance.dataValues[as]?.get(foreignKey)

Hello, please provide a reproduction of this in the demo environment.
https://a_8hwne7u84ho.v13.demo.nocobase.com/admin/ (NocoBase default account password)