-
Notifications
You must be signed in to change notification settings - Fork 14
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
feat: Prevent circular connections between nodes #321
Merged
Merged
+399
−32
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add validateConnection function to check node connections - Implement validation for self-references and circular dependencies - Throw errors for invalid connections in deriveFlows - Add comprehensive test cases for connection validation This commit adds validation to prevent circular dependencies and self-references in node connections, while allowing other operations like node deletion to proceed normally. The validation includes: - Self-reference detection - Circular dependency detection using DFS - Node existence validation - Node type validation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Add try-catch-finally blocks to ensure proper cleanup of persist timer even when applyActions throws an error. This maintains consistency between graph state updates and persistence scheduling. - Wrap graph state updates in try block - Add error logging and re-throw in catch block - Move timer cleanup and scheduling to finally block
Add GraphError class to provide structured error handling with user-friendly messages and system-level details. This improves error reporting when validating graph connections. - Add GraphError class with error codes and dual-message system - Update validateConnection to use GraphError for all error cases - Update deriveFlows to handle GraphError properly - Add error handling in properties panel when adding connections - Improve error messages to be more user-friendly
Update test assertions to check GraphError properties including: - error instance type - error code - user-friendly message - system message This aligns the tests with the new structured error handling implemented in the previous commit.
65fe56c
to
7b543e1
Compare
…ions The validateConnection function now checks for self-reference in both: - The new connection being added - Any existing connections in the graph - Update self-reference check in validateConnection - Add test case for detecting self-reference in existing connections
Remove NODE_NOT_FOUND and TYPE_MISMATCH error checks from validateConnection as they are redundant: - NODE_NOT_FOUND is prevented by UI constraints and active connection filtering - TYPE_MISMATCH cannot occur as connection types are derived from actual nodes
@shige @toyamarinyon review, please 🙏 |
shige
approved these changes
Feb 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🟢
toyamarinyon
approved these changes
Feb 13, 2025
Thank you for reviewers 🚀 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Implements validation to prevent circular dependencies in node connections, including self-references and connection loops. This ensures stable graph execution by preventing infinite loops and unpredictable behavior.
Related Issue
Closes #297
Changes
Testing
Other Information
The implementation uses an efficient DFS algorithm for cycle detection, ensuring good performance even with larger node graphs. The validation is performed before connection creation, providing immediate feedback to users when invalid connections are attempted.