Add a limit to entity hierarchy depth

Description

Add a limit to entity hierarchy depth. We currently have many SQL calls that recursively walk entities hierarchies. Each of these walks currently include a depth limit to prevent stack over flows or infinite loops. We need to block users from creating hierarchies deeper than our recursive walk limits.

Environment

None

Activity

Show:
Marco Marasca
February 26, 2021, 12:38 AM

Retried my script on staging and got back the expected response this time:

On synapse.org I do not see the "red" labels anymore when navigating to the deepest folder and I cannot upload a file in the leaf folder or create an additional nested folder: "Exceeded the maximum hierarchical depth of: 50 for parent: syn24992964"

John Hill
February 12, 2021, 9:15 PM

I can see the error when I added the following line to the test:

Produces

The nodeDAO.getEntityPathIds() limit is actually 49 and not 50;

Marco Marasca
February 12, 2021, 9:09 PM

I guess then the check is performed before the node manager? e.g. maybe at the entity service level? I used the python client to create the nested hierarchy through the API (unfortunately migration deleted my testing folder).

Maybe an API integration test would surface the issue? The message seem to come from the NodeDaoImpl.validatePath method.

John Hill
February 12, 2021, 8:54 PM

I am having trouble reproducing the errors you observed. The following test passes on develop:

Blocking the 50th child will result in a 400, and the 49th child is still available.

Marco Marasca
February 11, 2021, 3:24 AM
Edited

I tried running a script to create more than 50 nested folders:

Here 21918767 is a folder in a project (which is already at level 2).

But I got back the following 500 error:

I would expect a 4xx status code. Additionally now navigating to the latest nested folder that I created I get back a 500 (Path depth limit of: 50 exceeded for: syn24747304):

https://staging.synapse.org/#!Synapse:syn24747304

I can navigate to the parent of this folder: https://staging.synapse.org/#!Synapse:syn24747299 but the children shows the same red 500.

Fixed

Assignee

John Hill

Reporter

John Hill

Validator

Marco Marasca

Priority

Major

Labels

None

Development Area

None

Sprint

None

Fix versions

Release Version History

None

Story Points

None

Epic Link

None

Slack Channel

None