Skip to content

fix: pass unknown paint types through marked instead of throwing - #421

Open
gillianrode-123 wants to merge 1 commit into
GLips:mainfrom
gillianrode-123:fix/degrade-unknown-paint-types
Open

fix: pass unknown paint types through marked instead of throwing#421
gillianrode-123 wants to merge 1 commit into
GLips:mainfrom
gillianrode-123:fix/degrade-unknown-paint-types

Conversation

@gillianrode-123

Copy link
Copy Markdown

Problem

parsePaint throws on any paint type outside its known set (SOLID, IMAGE, PATTERN, the four gradients), and the throw fails the entire get_figma_data request. Paint types absent from the REST spec do reach real files: on 2026-08-22 we hit Figma code-component CUSTOM paints (customEffectId: "CodeComponentId:..." plus componentPropAssignments) on several nodes of a production file, and each one made its whole subtree uncapturable with Error fetching file: Unknown paint type: CUSTOM. Any future paint type Figma ships has the same effect until the transformer learns it.

Change

Unknown paint types degrade instead of throwing: parsePaint returns { type, unknownPaint: true, raw }, where raw is the untouched Figma paint object, and logs an error line. The fill is marked rather than silently dropped, so consumers can detect it (and still read the raw paint), while the rest of the simplification is unaffected. Adds SimplifiedUnknownFill to the SimplifiedFill union.

Backward compatibility

  • Output for all recognized paint types is unchanged.
  • Requests that previously failed outright now succeed with a marked fill entry; nothing that previously succeeded changes shape.
  • Downstream code that switches on fill type (e.g. image download collection matching "IMAGE") skips the unknown entry naturally.

Validation

  • 4 new vitest cases (src/tests/unknown-paint.test.ts): marked passthrough, raw-field preservation, known paints untouched, and stroke parsing surviving a mixed known/unknown paint list. Against the current code, 3 of 4 fail with the exact production error (Unknown paint type: CUSTOM); with the change, the full suite passes (254 passed / 1 skipped).
  • tsc --noEmit clean.

Relation to #420

Independent of #420 (different files, no overlap); both come out of the same production usage. Happy to rebase either if both are accepted.

🤖 Generated with Claude Code

parsePaint threw on any paint type outside its known set, and the throw
failed the entire get_figma_data request. Paint types absent from the
REST spec reach real files (Figma code-component CUSTOM paints, observed
2026-08-22), so one such paint on one node made a whole file/subtree
uncapturable.

Unknown paint types now return { type, unknownPaint: true, raw } with
the original paint preserved, log an error line, and leave the rest of
the simplification untouched.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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