editor icon indicating copy to clipboard operation
editor copied to clipboard

fix(nodes): guard missing roof-segment trim in ridge-vent geometry key (Sentry MONOREPO-EDITOR-ED)

Open anton-pascal opened this issue 4 months ago • 0 comments

Summary

  • tolerate roof segments whose stored data predates the trim schema field
  • keep the ridge-vent geometry dependency key stable by reading trim fields from an empty partial object when segment.trim is missing

Root cause

The public viewer hydrates raw stored nodes without re-running the Zod parser. For legacy roof segments, that means the RoofSegmentTrim schema default never applies and segment.trim can be undefined at runtime. ridgeVentSegmentGeometryKey then dereferenced trim.left, crashing the viewer.

buildRidgeVentGeometry already routes trim handling through normalizeRoofSegmentTrim, so no additional guard was needed there.

Sentry

  • MONOREPO-EDITOR-ED
  • Issue 7593979332
  • Observed July 22, 2026 on /viewer/project_myTyG1YFgGBVpS6O

Validation

  • bun test packages/nodes/src/ridge-vent/__tests__/geometry.test.ts — 18 pass, 0 fail
  • bunx biome check packages/nodes/src/ridge-vent/renderer.tsx — clean

[!NOTE] Low Risk Narrow defensive null-coalescing in a geometry cache key; no auth, data, or geometry-building logic changes beyond avoiding a runtime dereference.

Overview Fixes a viewer crash when legacy roof segments are hydrated without a trim field (Zod defaults never run on raw stored nodes in the public viewer).

ridgeVentSegmentGeometryKey now treats missing segment.trim as an empty partial object before reading trim fields for the memo dependency string, so undefined trim no longer throws when building ridge-vent geometry keys.

Reviewed by Cursor Bugbot for commit 25b7add31b631809b91e7de5d104223ac27a6b81. Bugbot is set up for automated code reviews on this repo. Configure here.

anton-pascal avatar Jul 22 '26 04:07 anton-pascal