fix(solvers): prevent crash on empty connections array - #816
Conversation
Fixes tscircuit#657 by adding null-safety checks to MspConnectionPairSolver and getConnectivityMapsFromInputProblem. Adds comprehensive unit tests in empty-connections-guard.test.ts.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 48c15d0ed1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| directConnections: [], | ||
| netConnections: [], |
There was a problem hiding this comment.
Cover omitted connection arrays in the regression test
This test still supplies both connection arrays, so it does not exercise the undefined case named by the test and commit; the same empty-array inputs would have been safe before this patch because for ... of [] is valid. When a pipeline caller actually omits these fields, the new local guards let MspConnectionPairSolver proceed, but downstream code such as NetLabelPlacementSolver.computeOverlappingSameNetTraceGroups() still dereferences this.inputProblem.directConnections/netConnections, so the crash can remain undetected. Please omit these fields in the regression test or normalize them on the input object before later solvers see it.
Useful? React with 👍 / 👎.
Summary
Fixes #657.
This PR adds safety guards to ensure solvers handle empty or undefined connection arrays (\directConnections: [],
etConnections: []) without throwing uncaught exceptions.
Changes
etConnections.
etConnections.
Verification