Skip to content

#1082: Start hardening wallet session hydrate against malformed storage - #1160

Closed
Ajibose wants to merge 2 commits into
LabsCrypt:mainfrom
Ajibose:fix/1082-wallet-session-hydrate-guard
Closed

#1082: Start hardening wallet session hydrate against malformed storage#1160
Ajibose wants to merge 2 commits into
LabsCrypt:mainfrom
Ajibose:fix/1082-wallet-session-hydrate-guard

Conversation

@Ajibose

@Ajibose Ajibose commented Jul 30, 2026

Copy link
Copy Markdown

Closes #1082

Summary

  • Trims the raw localStorage value before JSON.parse in readStoredSession

Not yet done

  • try/catch around the full hydrate/parse path with fallback to a clean disconnected state
  • Clearing the invalid stored value on failure (currently only handled for the empty/whitespace case)
  • Regression test in wallet-context.test.tsx with a malformed stored session

Test plan

  • Add regression test with malformed stored session
  • Manually corrupt flowfi.wallet.session.v1 in localStorage and confirm app doesn't crash

Ajibose and others added 2 commits July 30, 2026 12:19
Small first step toward LabsCrypt#1082. Full try/catch error boundary around
hydrate, clearing invalid stored sessions, and the regression test
still need to be added in a follow-up.
The existing "malformed session" test only covered valid JSON with an
unexpected shape. This adds a case with unparsable JSON to exercise
the JSON.parse catch path in readStoredSession, confirming hydrate
falls back to a clean disconnected state and clears the bad key.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@ogazboiz

ogazboiz commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

appreciate the intent, but main's readStoredSession already wraps JSON.parse in try/catch, validates the shape via isWalletSession and clears the bad key, so the hardening from #1082 is already in place. the only behavioral delta here is a trim() path that returns null without clearing the stored value, which is slightly worse than the existing catch path. closing. your regression test would pass against main as-is, so a tiny test-only PR is welcome. if you want to keep contributing, join us on Telegram: https://t.me/+DOylgFv1jyJlNzM0

@ogazboiz ogazboiz closed this Aug 3, 2026
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.

[Backend] frontend/src/context/wallet-context.tsx reducer has no error boundary for malformed persisted session JSON

2 participants