Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bot/modules/nostr/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ export const decodeNpub = (npub: string) => {
try {
const { type, data } = nip19.decode(npub);
if (type === 'npub') return data;
} catch (err) {}
} catch (err) {
return null;
}
Comment on lines +7 to +9

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Missing logging despite PR objective.

The PR description states this change adds "logging and a clear error return path," but the catch block only returns null — the caught error is discarded without any log call. If observability of malformed npub input was the intent, add a log statement here.

🐛 Proposed fix
   } catch (err) {
+    console.error('Failed to decode npub:', err);
     return null;
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} catch (err) {
return null;
}
} catch (err) {
console.error('Failed to decode npub:', err);
return null;
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@bot/modules/nostr/lib.ts` around lines 7 - 9, The catch block in the Nostr
parsing path discards the thrown error, so the promised logging is missing.
Update the error handling in the function containing the catch block to log the
caught `err` before returning `null`, using the existing logger or equivalent
observability mechanism, while keeping the clear null return path intact.

};
export const encodeNpub = (hex: string) => {
return nip19.npubEncode(hex);
Expand Down