Fix JSON.parse() on Hyperbee entry objects - parse data.value not data
SYSTEMATIC FIX using deep-debugging methodology:
Problem: "[object Object]" is not valid JSON
Location: lib/wallet-storage.cjs:1023 in getContactById()
Root Cause Analysis:
1. Hyperbee.get() returns: { key: '...', value: '...' }
2. The VALUE is JSON stringified, not the whole entry
3. getContactById() tried: JSON.parse(data) ← WRONG
4. Should be: JSON.parse(data.value) ← CORRECT
Verification:
- getContacts() already does this correctly (line 963)
- getTransactions() already does this correctly (line 506)
- Found same bug in getTransactionByHash() - fixed
Fixed in:
- getContactById(): JSON.parse(data) → JSON.parse(data.value)
- getTransactionByHash(): JSON.parse(data) → JSON.parse(data.value)
Added null check before parsing to prevent errors.
User report: "be more systematic in debugging this you are running in loops"
Deep debugging steps applied:
1. Read ACTUAL error from logs ✅
2. Trace exact failure point ✅
3. Check data format at each stage ✅
4. Compare with working code (getContacts) ✅
5. Fix root cause, not symptoms ✅
6. Check for same bug elsewhere ✅
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
b51bd86d9c34870eab6a6fc096333bd6b0030219
by plankatron <fleeky@gmail.com> · 2026-01-27T23:12:52.000Z