Skip to content

fix(app): recover from malformed session diffs#21127

Open
jeanibarz wants to merge 4 commits intoanomalyco:devfrom
jeanibarz:fix/21100-session-diff-array-guard
Open

fix(app): recover from malformed session diffs#21127
jeanibarz wants to merge 4 commits intoanomalyco:devfrom
jeanibarz:fix/21100-session-diff-array-guard

Conversation

@jeanibarz
Copy link
Copy Markdown

@jeanibarz jeanibarz commented Apr 5, 2026

Issue for this PR

Closes #21100

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The app currently assumes session_diff is either missing or a valid diff array. If malformed cached or event payloads get into that slot, session review paths can treat the state as loaded and eventually call array methods on invalid values.

This change keeps the fix narrowly scoped to that bug path:

  • validate session_diff payloads before they are treated as loaded
  • store malformed realtime or fetched diff payloads as undefined so review can refetch instead of freezing on bad state
  • harden the app readers that inspect session diffs during review/comment flows
  • add targeted regression tests for diff validation, malformed event handling, sync recovery, and session review readiness/fetch gating

How did you verify your code works?

  • cd packages/app && PATH=/tmp/bun-1.3.11/bin:$PATH bun test --preload ./happydom.ts src/context/sync-session-diff.test.ts src/context/global-sync/session-diff.test.ts src/context/global-sync/event-reducer.test.ts src/pages/session/review-diff-state.test.ts
  • cd packages/app && PATH=/tmp/bun-1.3.11/bin:$PATH bun typecheck
  • cd packages/app && PATH=/tmp/bun-1.3.11/bin:$PATH bun run test:unit

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@jeanibarz jeanibarz requested a review from adamdotdevin as a code owner April 5, 2026 20:31
@jeanibarz jeanibarz changed the title fix(app): harden session diff handling fix(app): recover from malformed session diffs Apr 5, 2026
@jeanibarz
Copy link
Copy Markdown
Author

Friendly ping — this is a small bug fix (guards against malformed session_diff payloads that cause e.diffs.map is not a function). All CI is green. Happy to address any feedback!

@jeanibarz jeanibarz force-pushed the fix/21100-session-diff-array-guard branch 2 times, most recently from c77bc4c to 9ca0687 Compare April 7, 2026 20:36
@jeanibarz jeanibarz force-pushed the fix/21100-session-diff-array-guard branch from 9ca0687 to 78cdbb8 Compare April 7, 2026 21:12
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.3.15, e.diffs.map is not a function

1 participant