Skip to content

fix(core): coerce unknown material.preset to 'custom' (Sentry MONOREPO-EDITOR-DB)#400

Open
anton-pascal wants to merge 1 commit into
mainfrom
fix/sentry-EDITOR-DB
Open

fix(core): coerce unknown material.preset to 'custom' (Sentry MONOREPO-EDITOR-DB)#400
anton-pascal wants to merge 1 commit into
mainfrom
fix/sentry-EDITOR-DB

Conversation

@anton-pascal

Copy link
Copy Markdown
Contributor

Problem

Production editor crashes with an unhandled ZodError during slab boundary edits (Sentry MONOREPO-EDITOR-DB, issue id 7543527892):

ZodError: invalid_value at ["material","preset"]
expected one of white|brick|concrete|wood|glass|metal|plaster|tile|marble|custom

Stack: polygon-editor.tsx → slab/boundary-editor handlePolygonChangeuse-scene updateNodeSlabNode.parse.

This happens when node data carries a material.preset value outside the MaterialPreset enum — typically legacy, imported, or AI-generated scenes (e.g. "stone").

Fix

In MaterialSchema, change:

preset: MaterialPreset.optional()

to:

preset: MaterialPreset.catch('custom').optional()

Unknown preset values are now coerced to 'custom' instead of throwing, making loading/updating tolerant of bad data. The exported MaterialPreset enum itself stays strict, so all other consumers keep exact enum validation. resolveMaterial already falls back to DEFAULT_MATERIALS.custom merged with material.properties for 'custom', so coerced materials render with whatever explicit properties the node carries.

Verified undefined handling: missing/undefined preset still parses to undefined (zod v4 .catch() before .optional() does not swallow undefined).

Tests

New packages/core/src/schema/material.test.ts:

  • valid presets pass through unchanged (all 10 enum values)
  • unknown preset ('stone') coerces to 'custom'
  • non-string preset coerces to 'custom'
  • missing / explicit-undefined preset stays undefined

bun test src/schema/ → 50 pass, 0 fail; tsc --build clean; biome check clean.

@mintlify

mintlify Bot commented Jun 12, 2026

Copy link
Copy Markdown

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

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

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

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