Skip to content

fix(solvers): prevent crash on empty connections array - #816

Open
rudra496 wants to merge 1 commit into
tscircuit:mainfrom
rudra496:fix/empty-connections-guard
Open

fix(solvers): prevent crash on empty connections array#816
rudra496 wants to merge 1 commit into
tscircuit:mainfrom
rudra496:fix/empty-connections-guard

Conversation

@rudra496

Copy link
Copy Markdown

Summary

Fixes #657.

This PR adds safety guards to ensure solvers handle empty or undefined connection arrays (\directConnections: [],
etConnections: []) without throwing uncaught exceptions.

Changes

  1. Added nullish coalescing to \getConnectivityMapsFromInputProblem.ts\ for \directConnections\ and
    etConnections.
  2. Added nullish coalescing to \MspConnectionPairSolver.ts\ across \chips, \pins, \directConnections, and
    etConnections.
  3. Created \ ests/solvers/SchematicTracePipelineSolver/empty-connections-guard.test.ts\ verifying that solving an \InputProblem\ with empty connection arrays succeeds cleanly.

Verification

  • \�un test tests/solvers/SchematicTracePipelineSolver/empty-connections-guard.test.ts\ (2/2 passing).

Fixes tscircuit#657 by adding null-safety checks to MspConnectionPairSolver and getConnectivityMapsFromInputProblem. Adds comprehensive unit tests in empty-connections-guard.test.ts.
Copilot AI lite review requested due to automatic review settings August 15, 2026 15:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@vercel

vercel Bot commented Aug 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
schematic-trace-solver Ready Ready Preview Aug 15, 2026 3:40pm

Request Review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +34 to +35
directConnections: [],
netConnections: [],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Router crashes on empty connections array

2 participants