Skip to content

fix: normalize clip.effects to prevent crash on missing params - #15

Open
murich wants to merge 1 commit into
HelpFreedom:mainfrom
murich:fix/effect-missing-params-crash
Open

fix: normalize clip.effects to prevent crash on missing params#15
murich wants to merge 1 commit into
HelpFreedom:mainfrom
murich:fix/effect-missing-params-crash

Conversation

@murich

@murich murich commented Sep 1, 2026

Copy link
Copy Markdown

Summary

  • Effect.params is typed as required (shared/types.ts), but nothing enforced that at runtime. A patch that sets clip.effects from outside the effects UI — kadr_eval, a hand-edited or foreign project file — can hand an effect object with no params.
  • BlurControls/GlowControls in Inspector.tsx both read fx.params directly with no guard, so selecting a clip carrying such an effect throws during render (Cannot read properties of undefined (reading 'size') at BlurControls).
  • There's no error boundary around this tree, so the uncaught error unmounts the whole app to a blank/black window — no console output visible to the user, no crash report anywhere, looks like a total hang.
  • Fix: normalize clip.effects (drop entries missing id/type, default params to {}) in the two places it can enter live state — updateClip (the single merge point every patch goes through) and sanitizeProject (project load, for foreign/hand-edited files).

Test plan

  • npx tsc --noEmit -p tsconfig.web.json passes
  • Manually repro: window.kadrEditor.useEditor.getState().updateClip(clipId, { effects: [{ id: 'x', type: 'blur', enabled: true }] }) (no params) then select the clip — should no longer crash

Effect.params is typed as required, but nothing enforced that at
runtime. A patch that sets clip.effects from outside the effects UI
(kadr_eval, a hand-edited or foreign project file) can hand an effect
object with no params. BlurControls and GlowControls in Inspector.tsx
both read fx.params directly with no guard, so selecting a clip
carrying such an effect throws during render:

  TypeError: Cannot read properties of undefined (reading 'size')
    at BlurControls

React has no error boundary around this tree, so the uncaught error
unmounts the whole app to a blank/black window with no console
output the user can see and no crash report anywhere.

Fix in the two places clip.effects can enter live state:
- updateClip (the single merge point every patch, including
  kadr_eval-issued ones, goes through) now filters out entries
  missing id/type and defaults params to {} after merging.
- sanitizeProject (run on project load) gets the same treatment, so
  a foreign/hand-edited project file is healed on open too, not just
  a live patch.
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