fix(editor): guard model export against undefined geometry.index (Sentry MONOREPO-EDITOR-E0)#447
fix(editor): guard model export against undefined geometry.index (Sentry MONOREPO-EDITOR-E0)#447anton-pascal wants to merge 1 commit into
Conversation
…x (Sentry EDITOR-E0)
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
Nightly Sentry triage (2026-06-29): MONOREPO-EDITOR-E0/6H |
|
Nightly Sentry triage (2026-07-06): MONOREPO-EDITOR-E0 is still firing in production (569 events on issue 6H/E0, latest 2026-07-05 20:42 UTC, release 7838320f). The fix on this branch is not yet on the deployed release — this PR is still needed. No duplicate opened. |
…index) Ports upstream PRs pascalorg#459 + pascalorg#447: undefined slots in array materials and a never-set geometry.index of undefined crashed GLTFExporter (Sentry MONOREPO-EDITOR-79 / -E0 upstream). One shared normalizeSceneForExport guard wired into both the viewer and editor export paths; repairs only touch already-broken state. Three tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sentry: MONOREPO-EDITOR-E0 / 6H
TypeError: Cannot read properties of undefined (reading 'count')thrown during STL/OBJ/GLB model export.Stack: settings-panel
onClick→ export-managerexportFn→ three'sSTLExporter.parse→Object3D.traverse.Root cause
three r184's
STLExporterdoes:A
BufferGeometrywhose index was never set reportsgeometry.index === undefined, notnull. The exporter's guardindex !== nullis therefore truthy forundefined, so it falls into theindex.countbranch and crashes readingundefined.count.BufferGeometrysemantically treatsnullas "no index" (non-indexed draw), which is the form all three exporters expect — but a freshly traversed/cloned mesh can carryundefinedinstead.Note: the export pipeline referenced in the original Sentry report (
export-manager.tsxwithisMeshWithInvalidGeometry/prepareSceneForExport) has since been refactored intopackages/editor/src/lib/glb-export.ts. The fix is applied there, inprepareSceneForExport, which is the shared prep path used by STL and OBJ and GLB exports.Fix
Add a minimal, defensive
normalizeGeometryIndex()pass that runs afterpruneNonRenderableMesheson the cloned export scene. For every surviving mesh, it coercesgeometry.indexfromundefined→null:Because it runs on the cloned export tree (never the live scene) and only touches the
undefinedcase, it's safe and idempotent. STL/OBJ/GLB all benefit.Test
Pre-existing monorepo cross-package typecheck errors (unbuilt
@pascal-app/viewer/coreworkspaces) are unrelated to this change; no new errors reference the added code.Note
Low Risk
Narrow defensive normalization on the export clone only, with no auth, persistence, or live-scene mutation.
Overview
Fixes STL/OBJ/GLB export crashes when a mesh’s
BufferGeometryhasgeometry.index === undefinedinstead ofnull. three r184 exporters treatundefinedas indexed geometry and readindex.count, which throws during export from the settings panel.Adds
normalizeGeometryIndex()on the cloned export scene inprepareSceneForExport, immediately afterpruneNonRenderableMeshes, settinggeometry.indexfromundefined→nullso non-indexed geometry matches what STL/OBJ/GLB paths expect. Only the export clone is touched; meshes that already have an index ornullare unchanged.Reviewed by Cursor Bugbot for commit e3d40d6. Bugbot is set up for automated code reviews on this repo. Configure here.