fix(app): guard diffs with Array.isArray to prevent .map crash#19221
Closed
ysm-dev wants to merge 2 commits intoanomalyco:devfrom
Closed
fix(app): guard diffs with Array.isArray to prevent .map crash#19221ysm-dev wants to merge 2 commits intoanomalyco:devfrom
ysm-dev wants to merge 2 commits intoanomalyco:devfrom
Conversation
Contributor
Author
|
The |
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.
Issue for this PR
Closes #19217
Type of change
What does this PR do?
props.diffs.mapinSessionReviewcrashes whendiffsis not an array. This happens when reopening old browser sessions because the SSE event reducer passesevent.properties.diffdirectly toreconcile()without validating it's an array. If the data is malformed or missing,reconcile(undefined, { key: "file" })can corrupt the store value into a non-array. The existing?? []fallback only catchesnull/undefined— a truthy non-array (like{}) passes through.The fix adds
Array.isArrayguards at four points:props.diffbeforereconcile()(root cause fix, matches the pattern already used insync.tsx)session_diff[id]read withArray.isArrayinstead of?? []summary.diffsread withArray.isArrayinstead of?? []props.diffsaccess in the UI component as last-resort defenseHow did you verify your code works?
bun typecheckpasses across all 13 packagesreconcile()to theSessionReviewcomponent to confirm all paths now guarantee an arrayScreenshots / recordings
N/A — no UI changes, this is a runtime crash fix.
Checklist