Skip to content

fix: improve error messages in getadmindm gift wrap decryption#143

Merged
arkanoider merged 1 commit into
MostroP2P:mainfrom
AndreaDiazCorreia:fix/unwrapping-getadmindm
Oct 9, 2025
Merged

fix: improve error messages in getadmindm gift wrap decryption#143
arkanoider merged 1 commit into
MostroP2P:mainfrom
AndreaDiazCorreia:fix/unwrapping-getadmindm

Conversation

@AndreaDiazCorreia
Copy link
Copy Markdown
Member

@AndreaDiazCorreia AndreaDiazCorreia commented Oct 5, 2025

Improved error handling in getadmindm by 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

    • Corrected the target key used for the Direct Messages (Admin) list to fetch the intended events, improving accuracy and completeness of the admin DM feed.
  • Chores

    • Added detailed warning messages when decrypting or parsing gift-wrapped messages fails. Failures no longer fail silently; users may see contextual warnings in logs while the app continues to operate normally.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 5, 2025

Walkthrough

Adds 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

Cohort / File(s) Summary
DM parsing warnings
src/parser/dms.rs
Replace ignored errors with captured errors to emit specific stderr warnings on GiftWrap decrypt and message parse failures; flow continues unchanged.
DirectMessagesAdmin fetch target key
src/util.rs
In fetch_events_list, for ListKind::DirectMessagesAdmin, switch filter target from ctx.mostro_pubkey to ctx.context_keys.public_key() with clarifying comment; logic otherwise unchanged.

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • grunch

Poem

I hop through logs with twitchy ears,
Decrypting whispers, facing fears.
If bytes won’t bloom, I leave a note—
“Couldn’t unwrap,” I politely quote.
I fetch with keys that match the scene,
Carrots, commits, and code kept clean. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title accurately reflects the primary change by indicating an improvement of error messages in the getadmindm gift wrap decryption flow. It is concise, highlights the specific area affected, and avoids unnecessary details, making it easy for reviewers to understand the main focus at a glance.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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 PrivateDirectMessage error 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5f4c207 and cbc8217.

📒 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 using mostro_pubkey.

@arkanoider arkanoider merged commit e56665c into MostroP2P:main Oct 9, 2025
1 check passed
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.

2 participants