-
Notifications
You must be signed in to change notification settings - Fork 872
fix(layout.DirectedGraph): better error message when dagre fails to connect to container #2838
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
base: master
Are you sure you want to change the base?
fix(layout.DirectedGraph): better error message when dagre fails to connect to container #2838
Conversation
ee6df96
to
8204e21
Compare
This PR is stale because it has been open 60 days with no activity. Please remove stale label or comment or this will be closed in 14 days. |
This PR is stale because it has been open 60 days with no activity. Please remove stale label or comment or this will be closed in 14 days. |
…onnect to container
8204e21
to
7f0eb64
Compare
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.
Pull Request Overview
Adds a new validation step to DirectedGraph.layout
to catch invalid links between container and child elements and introduces tests for both validation-enabled and disabled modes.
- Introduces a
validateGraph
method that throws a clear error when linking a child to its container. - Adds a
validateGraph
option to the layout API (defaulttrue
) and wires it intolayout
. - Adds QUnit tests covering scenarios where validation is on or off.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
packages/joint-layout-directed-graph/test/index.js | New QUnit test for container–child connection errors |
packages/joint-layout-directed-graph/DirectedGraph.mjs | Added validateGraph method and integrated its use |
Comments suppressed due to low confidence (1)
packages/joint-layout-directed-graph/DirectedGraph.mjs:123
- [nitpick] Enhance this error message with contextual information (e.g. source and target element IDs) to make debugging easier, for example:
DirectedGraph: cannot connect child ${source.id} to container ${target.id}
.
throw new Error('DirectedGraph: It is not possible to connect a child to a container.');
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.
Pull Request Overview
This PR adds pre-layout validation to DirectedGraph
to catch invalid parent/child connections earlier and provides clearer error messaging when such cases occur.
- Introduces
validateGraph
to detect links between containers and children before invoking Dagre. - Updates
layout
to callvalidateGraph
based on thevalidateGraph
option. - Adds new tests in
test/index.js
to verify the custom error message and fallback behavior when validation is disabled.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
packages/joint-layout-directed-graph/test/index.js | New QUnit tests covering invalid container/child links and error messages |
packages/joint-layout-directed-graph/DirectedGraph.mjs | Added validateGraph method and hooked it into layout |
Comments suppressed due to low confidence (1)
packages/joint-layout-directed-graph/DirectedGraph.mjs:126
- [nitpick] The error message only mentions "child to a container" but this validator also catches "container to child" and "container to container" cases. Consider updating the message (or making it parametric) to accurately reflect all invalid connection types.
throw new Error('DirectedGraph: It is not possible to connect a child to a container.');
This PR is stale because it has been open 60 days with no activity. Please remove stale label or comment or this will be closed in 14 days. |
Description
Provides a better error message when dagre fails due to trying to connect a child to a container.
See #455 for more information and workarounds.