kitware-resonant / dkc-next

Apache License 2.0
3 stars 0 forks source link

Test enforcement of max tree depth #6

Closed zachmullen closed 3 years ago

zachmullen commented 4 years ago

We need to see what kind of failure happens when someone attempts to exceed the max tree depth in treebeard to make sure we can present it properly to users.

Action item: catch treebeard.exceptions.PathOverflow in our code where we create or update folders, and make sure an appropriate error is returned to the user (should be 4xx via REST).

zachmullen commented 4 years ago

Result:

$ docker-compose run --rm django ./manage.py mock_db 60 1
Starting dkc-next_postgres_1 ... done
Starting dkc-next_rabbitmq_1 ... done
Starting dkc-next_minio_1    ... done
Traceback (most recent call last):
  File "./manage.py", line 20, in <module>
    main()
  File "./manage.py", line 16, in main
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.8/site-packages/djclick/adapter.py", line 68, in run_from_argv
    exit_code = self.main(
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/site-packages/djclick/adapter.py", line 50, in invoke
    return super(DjangoCommandMixin, self).invoke(ctx)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/opt/django/dkc/core/management/commands/mock_db.py", line 24, in command
    _populate_subtree(root_folder, depth - 1, branching)
  File "/opt/django/dkc/core/management/commands/mock_db.py", line 14, in _populate_subtree
    _populate_subtree(child, depth - 1, branching)
  File "/opt/django/dkc/core/management/commands/mock_db.py", line 14, in _populate_subtree
    _populate_subtree(child, depth - 1, branching)
  File "/opt/django/dkc/core/management/commands/mock_db.py", line 14, in _populate_subtree
    _populate_subtree(child, depth - 1, branching)
  [Previous line repeated 46 more times]
  File "/opt/django/dkc/core/management/commands/mock_db.py", line 13, in _populate_subtree
    folder.add_child(instance=child)  # equivalent to .save()
  File "/usr/local/lib/python3.8/site-packages/treebeard/mp_tree.py", line 1022, in add_child
    return MP_AddChildHandler(self, **kwargs).process()
  File "/usr/local/lib/python3.8/site-packages/treebeard/mp_tree.py", line 381, in process
    raise PathOverflow(
treebeard.exceptions.PathOverflow: The new node is too deep in the tree, try increasing the path.max_length property and UPDATE your database