Skip to content

fix(editor): guard door segments and columnRatios against undefined#303

Merged
Aymericr merged 1 commit into
mainfrom
fix/sentry-EDITOR-AM
Jun 3, 2026
Merged

fix(editor): guard door segments and columnRatios against undefined#303
Aymericr merged 1 commit into
mainfrom
fix/sentry-EDITOR-AM

Conversation

@anton-pascal
Copy link
Copy Markdown
Contributor

@anton-pascal anton-pascal commented May 12, 2026

Problem

Sentry issue EDITOR-AM — TypeError: Cannot read properties of undefined (reading 'length') in door-system.tsx (487 events) AND escalating issue Cannot read properties of undefined (reading 'some') (1.8k events).

In door-system.tsx, the code accesses segments.some and seg.columnRatios.length without null guards. Legacy door nodes in the database may lack these fields because they were added later to the Zod schema with a default value. When the viewer loads these nodes directly from the DB, the fields are undefined.

Fix

  • Added defensive fallback: segments ?? [] for all array iterations.
  • Added defensive fallback: seg.columnRatios ?? [1] (matches Zod default).
  • Added defensive fallback: seg.dividerThickness ?? 0.03 (matches Zod default).

@mintlify
Copy link
Copy Markdown

mintlify Bot commented May 12, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
pascal 🔴 Failed May 12, 2026, 4:06 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@anton-pascal anton-pascal force-pushed the fix/sentry-EDITOR-AM branch from 1e3e602 to bd789e0 Compare May 18, 2026 10:06
@anton-pascal anton-pascal changed the title fix(editor): guard door segment columnRatios against undefined fix(editor): guard door segments and columnRatios against undefined May 18, 2026
…nder

Legacy/unparsed door nodes can miss schema-defaulted fields (segments,
columnRatios, dividerThickness, panelInset/panelDepth …) and crash the
geometry build (EDITOR-AM: segments.some / seg.columnRatios.length on
undefined). updateDoorMesh now re-applies the Zod defaults once at entry via
DoorNodeSchema.safeParse (with a drop-bad-segments retry and a defaults
fallback), so every downstream read sees populated data — including the
shaped-top divider path #334 added. Also normalizes schema-valid legacy
doors at load in migrateNodes, mirroring the existing stair normalizer, so
the door panel and window system see defaulted data too.

Reimplements #303 with the real schema defaults (the original used
segments ?? [] — wrong: legacy doors rendered an empty frame — and missed
the #334 dividerThickness sites).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Aymericr Aymericr force-pushed the fix/sentry-EDITOR-AM branch from bd789e0 to d5c9a74 Compare June 3, 2026 20:07
@Aymericr Aymericr merged commit d926ded into main Jun 3, 2026
0 of 2 checks passed
@Aymericr Aymericr deleted the fix/sentry-EDITOR-AM branch June 3, 2026 20:07
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.

2 participants