Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loop detection in object hierarchies #5053

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

gjvoosten
Copy link
Collaborator

@gjvoosten gjvoosten commented Jan 23, 2025

When merging organizations/locations, it was possible to create loops in the hierarchy. This is now prevented.
Also, in the case of (pre-existing) loops, PostgreSQL and the GUI client no longer go into an infinite recursion.
And if the GUI client detects a loop, an error is logged on the server.

Closes AB#1233

User changes

  • None

Superuser changes

  • None

Admin changes

  • If merging organizations/locations would create a loop, you now get a clear error message preventing you from completing the merge.

System admin changes

  • application.yml or anet-dictionary.yml needs change
  • db needs migration
  • documentation has changed
  • graphql schema has changed

Checklist

  • described the user behavior in PR body
  • referenced/updated all related issues
  • commits follow a repo#issue: Title title format and these 7 rules
  • commits have a clean history, otherwise PR may be squash-merged
  • added and/or updated unit tests
  • added and/or updated e2e tests
  • added and/or updated data migrations
  • updated documentation
  • resolved all build errors and warnings
  • opened debt issues for anything not resolved here

@gjvoosten gjvoosten added the bug label Jan 23, 2025
@gjvoosten gjvoosten marked this pull request as ready for review January 23, 2025 14:34
@gjvoosten gjvoosten requested review from midmarch and jlnat January 23, 2025 14:34
When there were parent-child loops in the database, PostgreSQL would go
into an infinite loop on our WITH RECURSIVE queries. Replace UNION ALL
with simply UNION in these, as we don't need to know the depth; this
makes PostgreSQL discard duplicates, and thus avoid infinite recursion.
When there were parent-child loops in the database,
getAscendantObjectsAsList() would go into an infinite loop. Prevent this
by adding loop detection, breaking the loop in such a case, and logging
an error on the browser console and on the server.
@gjvoosten gjvoosten force-pushed the AB-1233-fix-loop-detection branch from 8555839 to d04a4e4 Compare January 28, 2025 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant