Skip to content

docs: changelog for msg_secret semaphore fix (whatsapp-rust#832) - #306

Closed
jlucaso1 wants to merge 1 commit into
mainfrom
claude/eager-cerf-bvw5vk
Closed

docs: changelog for msg_secret semaphore fix (whatsapp-rust#832)#306
jlucaso1 wants to merge 1 commit into
mainfrom
claude/eager-cerf-bvw5vk

Conversation

@jlucaso1

@jlucaso1 jlucaso1 commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a changelog entry for oxidezap/whatsapp-rust#832 — the bug fix that routes get_msg_secret and get_msg_secret_with_ts through with_semaphore instead of raw spawn_blocking.

  • New file changelog/2026-06-10-msg-secret-semaphore.mdx documenting the bug, root cause, and fix
  • docs.json updated to list the new entry at the top of the June 10 changelog group

What changed in the library

get_msg_secret / get_msg_secret_with_ts on SqliteStore previously used tokio::task::spawn_blocking directly, bypassing the single-permit db_semaphore. On in-memory (:memory:) stores a read racing a write transaction would get SQLITE_LOCKED, which both call sites silently treated as a lookup miss. The write-behind drain from #831 made this race consistently reachable, causing encrypted reactions and comments to arrive undecrypted. The fix routes both reads through with_semaphore so they wait rather than fail.

Breaking changes

None.


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Fixed race condition causing secret decryption failures in in-memory SQLite databases. Read operations now properly wait for concurrent writes to complete, preventing lookup misses.
  • Documentation

    • Added changelog entry documenting the decryption fix.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR documents a bug fix for SQLite in-memory read/write race conditions. The changelog entry describes how get_msg_secret and get_msg_secret_with_ts now use the with_semaphore mechanism to prevent reads from bypassing the write-path single-permit lock, avoiding silent decryption failures. The navigation config is updated to surface the new changelog entry.

Changes

SQLite Semaphore Bug Fix Documentation

Layer / File(s) Summary
Changelog entry and navigation
changelog/2026-06-10-msg-secret-semaphore.mdx, docs.json
Changelog documents the fix where get_msg_secret and get_msg_secret_with_ts now route through with_semaphore to prevent in-memory SQLite reads from bypassing the write lock and failing silently with SQLITE_LOCKED errors during write/read races. Navigation entry is added to expose the changelog.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A semaphore waits for its turn,
No more phantom reads that burn—
In-memory SQLite dances aligned,
With locks and order, peace of mind!
📝 ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding a changelog entry for a semaphore fix to the msg_secret database operations, with the related issue reference (#832).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/eager-cerf-bvw5vk

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with 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.

Inline comments:
In `@changelog/2026-06-10-msg-secret-semaphore.mdx`:
- Around line 10-16: Rewrite the changelog entry into active voice and address
the reader directly using second person; clearly state what you changed and why,
e.g., "You previously dispatched get_msg_secret and get_msg_secret_with_ts via
raw spawn_blocking, which bypassed the db_semaphore; this could cause
SQLITE_LOCKED on :memory: stores and silent misses because busy_timeout didn’t
apply. You now call those methods via with_semaphore so reads wait for the
single-permit write and avoid phantom misses. Note the relation to the
write-behind drain (`#831`) and symptom (undecrypted reactions/comments introduced
in `#829`), and list affected stores (in-memory :memory: only; file-backed WAL not
affected)."
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0312eae6-b1bc-4a96-9653-7eda5e1e6693

📥 Commits

Reviewing files that changed from the base of the PR and between a898637 and 3cfcfcd.

📒 Files selected for processing (2)
  • changelog/2026-06-10-msg-secret-semaphore.mdx
  • docs.json

Comment on lines +10 to +16
`get_msg_secret` and `get_msg_secret_with_ts` were dispatched via raw `spawn_blocking`, bypassing the single-permit `db_semaphore` that all write paths (and most other reads) already acquire via `with_semaphore`. On in-memory (`:memory:`) stores a read that overlaps an active write transaction hits the shared-cache table lock and fails with `SQLITE_LOCKED` — an error not covered by `busy_timeout`. Both call sites treat a backend error as a lookup miss, so the failure was silent.

In practice, the write-behind drain introduced in [#831](https://github.com/oxidezap/whatsapp-rust/pull/831) made this race consistently reachable: the detached batch write could race the very next incoming message's secret lookup. The symptom was encrypted reactions and channel comments (added in [#829](https://github.com/oxidezap/whatsapp-rust/pull/829)) arriving undecrypted, with no error logged.

Both methods now go through `with_semaphore`. A read that arrives during a write waits for the permit instead of failing as a phantom miss.

**Affected stores:** in-memory (`:memory:`) SQLite — used by the test suite and any embedded consumer. File-backed stores with WAL mode are not affected (WAL readers do not block on concurrent writers).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Rewrite to use active voice and second person per documentation guidelines.

The description uses passive voice and third person, violating the documentation style guidelines. Changelog entries are user-facing documentation and should address the reader directly.

As per coding guidelines, documentation should use active voice and second person ("you"). The guideline text states: "Use active voice and second person ('you') in documentation."

♻️ Suggested rewrite in active voice and second person
-`get_msg_secret` and `get_msg_secret_with_ts` were dispatched via raw `spawn_blocking`, bypassing the single-permit `db_semaphore` that all write paths (and most other reads) already acquire via `with_semaphore`. On in-memory (`:memory:`) stores a read that overlaps an active write transaction hits the shared-cache table lock and fails with `SQLITE_LOCKED` — an error not covered by `busy_timeout`. Both call sites treat a backend error as a lookup miss, so the failure was silent.
+Previously, if you used `get_msg_secret` or `get_msg_secret_with_ts`, the calls dispatched via raw `spawn_blocking` and bypassed the single-permit `db_semaphore`. Write paths and most other reads already acquire this semaphore via `with_semaphore`. When you run an in-memory (`:memory:`) store and a read overlaps an active write transaction, the read hits the shared-cache table lock. It then fails with `SQLITE_LOCKED` — an error `busy_timeout` does not cover. The call sites treated backend errors as lookup misses, so you saw silent failures.

-In practice, the write-behind drain introduced in [`#831`](https://github.com/oxidezap/whatsapp-rust/pull/831) made this race consistently reachable: the detached batch write could race the very next incoming message's secret lookup. The symptom was encrypted reactions and channel comments (added in [`#829`](https://github.com/oxidezap/whatsapp-rust/pull/829)) arriving undecrypted, with no error logged.
+The write-behind drain from [`#831`](https://github.com/oxidezap/whatsapp-rust/pull/831) made this race consistently reachable. The detached batch write could race your next incoming message's secret lookup. You would see encrypted reactions and channel comments (from [`#829`](https://github.com/oxidezap/whatsapp-rust/pull/829)) arrive undecrypted. No error appeared in your logs.

-Both methods now go through `with_semaphore`. A read that arrives during a write waits for the permit instead of failing as a phantom miss.
+Both methods now route through `with_semaphore`. When your read arrives during a write, it waits for the permit instead of failing as a phantom miss.

-**Affected stores:** in-memory (`:memory:`) SQLite — used by the test suite and any embedded consumer. File-backed stores with WAL mode are not affected (WAL readers do not block on concurrent writers).
+**Affected stores:** This fix applies when you use in-memory (`:memory:`) SQLite — common in test suites and embedded consumers. If you use file-backed stores with WAL mode, you are not affected (WAL readers do not block on concurrent writers).
🤖 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 `@changelog/2026-06-10-msg-secret-semaphore.mdx` around lines 10 - 16, Rewrite
the changelog entry into active voice and address the reader directly using
second person; clearly state what you changed and why, e.g., "You previously
dispatched get_msg_secret and get_msg_secret_with_ts via raw spawn_blocking,
which bypassed the db_semaphore; this could cause SQLITE_LOCKED on :memory:
stores and silent misses because busy_timeout didn’t apply. You now call those
methods via with_semaphore so reads wait for the single-permit write and avoid
phantom misses. Note the relation to the write-behind drain (`#831`) and symptom
(undecrypted reactions/comments introduced in `#829`), and list affected stores
(in-memory :memory: only; file-backed WAL not affected)."

Source: Coding guidelines

@mintlify

mintlify Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
whatsapp-rust 🟢 Ready View Preview Jun 10, 2026, 4:52 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

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.

1 participant