Skip to content

fix(utils): guard null in checkAndFixMas + removeTrailingZeroes#10

Open
gpitel wants to merge 1 commit into
OpenMagnetics:mainfrom
gpitel:fix/builder-null-guards-upstream
Open

fix(utils): guard null in checkAndFixMas + removeTrailingZeroes#10
gpitel wants to merge 1 commit into
OpenMagnetics:mainfrom
gpitel:fix/builder-null-guards-upstream

Conversation

@gpitel

@gpitel gpitel commented Jun 29, 2026

Copy link
Copy Markdown

Summary

Two pre-existing null-handling gaps in assets/js/utils.js, both surfaced by real designs:

  • checkAndFixMas — a just-added winding can leave a null excitation in excitationsPerWinding. The signal loop then dereferences exc[signal] and throws, which crashed WireInfo / BasicCoreSelector on mount and made the wire-configuration step unusable. Skip null entries.
  • removeTrailingZeroesnull/undefined slip past isNaN()/isFinite(), then value.toFixed() throws. This crashed WaveformOutput rendering, so the Operating Point view failed to render. Return early for null.

Change

-    if (isNaN(value) || !isFinite(value)) {
+    if (value == null || isNaN(value) || !isFinite(value)) {

   for (const exc of op.excitationsPerWinding) {
+      if (exc == null) continue;
       for (const signal of ['current', 'voltage']) {

Minimal, defensive, no behavior change for valid inputs. +2/−1.

🤖 Generated with Claude Code

Two pre-existing null-handling gaps surfaced by real designs:
- checkAndFixMas: a just-added winding can leave a null excitation; skip null
  entries instead of dereferencing exc.current (crashed WireInfo/BasicCoreSelector
  on mount, making wire config unusable).
- removeTrailingZeroes: null/undefined slip past isNaN()/isFinite(), then
  value.toFixed() throws; return early for null (crashed WaveformOutput render,
  so the Operating Point view failed to render).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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