Skip to content

Commit 5b72682

Browse files
committed
crate iteration global
1 parent 44957cd commit 5b72682

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

  • synapseclient/extensions/curator

synapseclient/extensions/curator/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
from synapseclient.models import Project
33
from synapseclient.operations import get
44

5+
"""This number represents a safeguard against infinite loops when traversing the folder hierarchy to find the project ID."""
6+
MAX_HIERARCHY_DEPTH = 1000
7+
58

69
def project_id_from_entity_id(entity_id: str, synapse_client: Synapse) -> str:
710
"""
@@ -24,6 +27,6 @@ def project_id_from_entity_id(entity_id: str, synapse_client: Synapse) -> str:
2427
while not isinstance(current_obj, Project):
2528
current_obj = get(current_obj.parent_id, synapse_client=synapse_client)
2629
iterations += 1
27-
if iterations > 1000:
30+
if iterations > MAX_HIERARCHY_DEPTH:
2831
raise ValueError("Could not find project ID in folder hierarchy")
2932
return current_obj.id

0 commit comments

Comments
 (0)