Skip to content

Surface real simulation error in schsim instead of generic "no graphs" message - #1688

Open
rushabhcodes wants to merge 2 commits into
tscircuit:mainfrom
rushabhcodes:fix/surface-schsim-simulation-error
Open

Surface real simulation error in schsim instead of generic "no graphs" message#1688
rushabhcodes wants to merge 2 commits into
tscircuit:mainfrom
rushabhcodes:fix/surface-schsim-simulation-error

Conversation

@rushabhcodes

Copy link
Copy Markdown
Contributor

Problem

The schematic-simulation (svg_type=schsim) endpoint reports:

Compilation Error — No simulation_transient_voltage_graph elements found for simulation_experiment_id "simulation_experiment_0"

This is a symptom, not the cause. When a SPICE run fails, @tscircuit/core catches the engine error and inserts a simulation_unknown_experiment_error element (carrying the real ngspice message) instead of producing any graphs. circuit-to-svg then throws the generic "no graphs found" error, masking the actual failure.

Fix

handlers/schematic-simulation-svg.ts now scans the circuit JSON for simulation_unknown_experiment_error elements matching the resolved experiment id (or with no experiment id, since core may leave it undefined) and throws the real message. It flows through errorResponse into the same "Compilation Error" box, so users see the actual cause instead of the generic text.

Tests

Adds tests/schematic-simulation-error-svg.test.ts:

  1. Positive — an ammeter + voltage-probe board renders a schsim SVG (status 200, contains the experiment id and the VOUT voltage graph id).
  2. Error-surfacing — reproduces a SPICE failure (drops the graphs, injects a simulation_unknown_experiment_error) and asserts the real message surfaces while the generic "No simulation_transient_voltage_graph elements found" does not. Fails without the handler change.

Existing tests/schematic-simulation-svg.test.ts still passes; changes are biome-formatted.

🤖 Generated with Claude Code

…" message

When a SPICE run fails, tscircuit-core inserts a
simulation_unknown_experiment_error element carrying the real failure
message (e.g. the underlying ngspice error) instead of producing any
simulation_transient_voltage_graph elements. circuit-to-svg then only
reports the generic "No simulation_transient_voltage_graph elements
found" message, masking the actual cause.

The schsim handler now detects simulation_unknown_experiment_error
elements for the resolved experiment id (or with no experiment id, since
core may leave it undefined) and throws the real message, which flows
through errorResponse into the same "Compilation Error" box.

Adds tests covering both a successful ammeter board render and the
error-surfacing path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 27, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
svg-tscircuit-com Ready Ready Preview, Comment Jun 27, 2026 5:45pm

Request Review

Comment thread tests/schematic-simulation-error-svg.test.ts Outdated
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.

1 participant