bug(node): naive JSON string extractor truncates values — DID mailbox IDs break relay drain

Open
#25 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust

Research direction

Start by reading extract_json_str in src/storage.rs:264-270 and the replay parser in src/envelope_wal.rs:42-48, then trace the listed call sites in http_relay.rs, http_federation.rs, federation_client.rs, and did_web.rs. Check how JSON string parsing handles escapes and field order. Done means a DID mailbox ID survives POST, WAL replay, and drain under the full key, with the requested Rust checks passing.

Written by the indexing model from the issue text.

Description

area::node effort::m impact::high priority::medium source::auto status::review type::bug

Context

Found during the final sandbox E2E run (2026-11-20): a direct POST /v1/relay/envelopes with "recipient_mailbox_id":"did:sonaraim:relay<ts>" returned 202, but GET /v1/relay/mailboxes/did:sonaraim:relay<ts> drained empty. The WAL shows the stored key truncated ("recipient_mailbox_id":"did:sonaraim:e2e-").

Symptom and mechanism (evidence)

extract_json_str (src/storage.rs:264-270) scans for "key":" then takes everything up to the NEXT ". The envelope replay parser in src/envelope_wal.rs:42-48 uses the same naive scanner. Hand-rolled scanning is order- and content-fragile: key-order changes or quote-bearing values silently corrupt routing keys. The B2B→node path happened to work because its payload field order differs — luck, not correctness.

Impact

High: relay routing keys are silently mangled for DID-format mailbox IDs; delivery appears successful (202/wake token) while the message lands under a truncated key the recipient never drains. Data loss shaped as success.

Acceptance criteria

  • Replace the naive scanners with a real JSON string parser (handle escapes, ignore key order) in storage.rs + all call sites (envelope_wal.rs, http_relay.rs, http_federation.rs, federation_client.rs, did_web.rs).
  • Regression test: envelope with colon-bearing recipient_mailbox_id (DID form) round-trips POST → WAL replay → drain under the FULL key.
  • cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo test green.
Dominant language
Rust
Stars
0
Forks
0
Avg merge
4m
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from alfonsodg/sonaraim-node

All issues in alfonsodg/sonaraim-node

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.