fix(nodes): guard missing roof-segment trim in ridge-vent geometry key (Sentry MONOREPO-EDITOR-ED) - #530
Conversation
Roof-segments migrated on scene load are cast rather than zod-parsed, so a segment saved before `trim` existed reaches the renderer with the field absent and the geometry key crashed reading `trim.left` off undefined. Route the key through core's `normalizeRoofSegmentTrim`, matching what `use-segment-trim-clip` and `ridge-vent/geometry` already do. Besides handling the absent field, this makes the cache key agree with the trim the geometry is actually built from — an out-of-range trim normalizes to a clamped value, so keying on the raw field could otherwise vary while the built mesh did not. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
25b7add to
1cdf09a
Compare
|
Confirmed the crash is reachable and taken this slightly further than the original patch. Why the null is real, since it is worth recording: What I changed. The patch used It also fixes a second, quieter problem. Added a regression test in Pushed to |
Summary
trimschema fieldsegment.trimis missingRoot cause
The public viewer hydrates raw stored nodes without re-running the Zod parser. For legacy roof segments, that means the
RoofSegmentTrimschema default never applies andsegment.trimcan beundefinedat runtime.ridgeVentSegmentGeometryKeythen dereferencedtrim.left, crashing the viewer.buildRidgeVentGeometryalready routes trim handling throughnormalizeRoofSegmentTrim, so no additional guard was needed there.Sentry
7593979332/viewer/project_myTyG1YFgGBVpS6OValidation
bun test packages/nodes/src/ridge-vent/__tests__/geometry.test.ts— 18 pass, 0 failbunx biome check packages/nodes/src/ridge-vent/renderer.tsx— cleanNote
Low Risk
Small defensive change in ridge-vent rendering; aligns geometry key with existing normalization used elsewhere.
Overview
Fixes a viewer crash when ridge vents render on legacy roof segments that were saved before the
trimfield existed. The public viewer hydrates nodes without re-running Zod, sosegment.trimcan beundefinedeven though parsed segments get defaults.ridgeVentSegmentGeometryKeynow builds its cache key fromnormalizeRoofSegmentTrim(segment)instead of readingsegment.trimdirectly, matching howbuildRidgeVentGeometryalready handles trim. A core test documents that segments with notrimat all normalize to zero trim.Reviewed by Cursor Bugbot for commit 1cdf09a. Bugbot is set up for automated code reviews on this repo. Configure here.