fix: normalize clip.effects to prevent crash on missing params - #15
Open
murich wants to merge 1 commit into
Open
fix: normalize clip.effects to prevent crash on missing params#15murich wants to merge 1 commit into
murich wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Effect.paramsis typed as required (shared/types.ts), but nothing enforced that at runtime. A patch that setsclip.effectsfrom outside the effects UI —kadr_eval, a hand-edited or foreign project file — can hand an effect object with noparams.BlurControls/GlowControlsinInspector.tsxboth readfx.paramsdirectly with no guard, so selecting a clip carrying such an effect throws during render (Cannot read properties of undefined (reading 'size')atBlurControls).clip.effects(drop entries missingid/type, defaultparamsto{}) in the two places it can enter live state —updateClip(the single merge point every patch goes through) andsanitizeProject(project load, for foreign/hand-edited files).Test plan
npx tsc --noEmit -p tsconfig.web.jsonpasseswindow.kadrEditor.useEditor.getState().updateClip(clipId, { effects: [{ id: 'x', type: 'blur', enabled: true }] })(noparams) then select the clip — should no longer crash