OverviewFilesCommitsIssuesDocsReleasesPeers

hyper-wallet commits / b51bd86

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

Changed files (1) +4 -2

lib/wallet-storage.cjs +4 -2
……@@ -625,7 +625,8 @@ async function getTransaction(chain, hash) {
625625
626626 try {
627627 const data = await txHistoryDb.get(`tx:${chain}:${hash}`)
628 const tx = JSON.parse(data)
628 if (!data) return null
629 const tx = JSON.parse(data.value)
629630
630631 // Handle case where tx or its fields might be null/undefined
631632 if (!tx) {
……@@ -1020,7 +1021,8 @@ async function getContactById(id) {
10201021
10211022 try {
10221023 const data = await txHistoryDb.get(`contact:${id}`)
1023 return JSON.parse(data)
1024 if (!data) return null
1025 return JSON.parse(data.value)
10241026 } catch (err) {
10251027 if (err.code === 'LEVEL_NOT_FOUND') {
10261028 return null