fix: improve error messages in getadmindm gift wrap decryption#143
Conversation
…bkey for DM filtering
WalkthroughAdds detailed stderr warnings in DMS parsing when decryption or content parsing fails, without changing control flow. Adjusts the fetch filter for DirectMessagesAdmin to use the current context public key (ctx.context_keys.public_key()) instead of a fixed mostro_pubkey. No API surface changes. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant CLI
participant Util as Util::fetch_events_list
participant Parser as Parser::DMS
note over CLI,Util: Fetch DirectMessagesAdmin using ctx.context_keys.public_key()
User->>CLI: Request DM admin list
CLI->>Util: fetch_events_list(ListKind::DirectMessagesAdmin)
Util-->>CLI: Events
CLI->>Parser: Parse events
alt Decrypt/parse succeeds
Parser-->>CLI: Parsed messages
else Decrypt fails
rect rgba(255,235,205,0.6)
note right of Parser: Warning: Could not decrypt gift wrap (event ...)
end
Parser-->>CLI: Continue next event
else Parse fails
rect rgba(221,235,247,0.6)
note right of Parser: Warning: Could not parse message content (event ...)
end
Parser-->>CLI: Continue next event
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/parser/dms.rs (1)
28-30: LGTM! Enhanced error diagnostics for gift wrap processing.The detailed warnings with event IDs and error messages will significantly aid debugging, as intended by issue #141. The use of
eprintln!for stderr output is appropriate, and the control flow is preserved correctly.Consider adding similar detailed warnings to the
PrivateDirectMessageerror paths (lines 46-73) for consistency and comprehensive diagnostics:let ck = if let Ok(ck) = ConversationKey::derive(pubkey.secret_key(), &dm.pubkey) { ck } else { eprintln!("Warning: Could not derive conversation key (event {})", dm.id); continue; };And similar patterns for the other error cases in that branch.
Also applies to: 36-38
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/parser/dms.rs(1 hunks)src/util.rs(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-13T10:31:42.313Z
Learnt from: arkanoider
PR: MostroP2P/mostro-cli#135
File: src/cli/get_dm.rs:24-29
Timestamp: 2025-09-13T10:31:42.313Z
Learning: In mostro-cli's get_dm.rs, the message filtering is intentional: non-admin users should only receive DirectMessage from users, while messages from Mostro are only fetched when the admin flag is true. Don't include GiftWrap messages for non-admin users.
Applied to files:
src/util.rs
🔇 Additional comments (1)
src/util.rs (1)
570-571: Approve context_keys.public_key() for DirectMessagesAdmin filter. This matches the admin send path and existing tests; orders and disputes continue usingmostro_pubkey.
Improved error handling in
getadmindmby replacing generic "Error unwrapping gift" messages with detailed warnings that include event IDs and specific error reasons for better debugging.issue #141
Summary by CodeRabbit
Bug Fixes
Chores