fix(chatwoot-adapter): harden history backfill from deep review (#609)#28
Merged
Conversation
Deep review of the v0.3.0 backfill surfaced defects fixed here (still pre-release, so folded into v0.3.0): - Add the engine:read permission — the sandboxed adapter could not call engine.getChatHistory/getChats without it, so backfill was rejected at the host gate. Bump minOpenWAVersion to 0.8.6 (the sandbox-bridged capability). - Bulk sweep now fetches history BEFORE creating a conversation and skips a chat with no fetchable history, so an engine without history support (Baileys) or an empty chat no longer floods Chatwoot with empty conversations. - Per-message isolation in replay: one failed post is logged and skipped instead of aborting the rest of the chat, and a message is marked seen only AFTER a successful post so a transient error stays retryable, not a silent drop. - Accept the string "true" for backfillAllOnce, not only the boolean. Historical location coordinates and quoted-message threading now render via the 0.8.6 engine enrichment (no adapter change needed).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pre-release hardening of the v0.3.0 history backfill (still unreleased), from a deep source-traced review. Pairs with OpenWA 0.8.6.
Fixes
engine:readpermission added. The sandboxed adapter now callsengine.getChatHistory/getChats; without the permission the host gate (resolveEngineRead) rejected them, so backfill silently no-op'd.minOpenWAVersion→ 0.8.6 (which bridgesengine.getChatHistoryinto the sandbox and enriches historical location/quote).ensureConversationand skips a chat with no fetchable history — so an engine without history support (Baileys, which rejects) or an empty chat can't flood Chatwoot with empty conversations.backfillAllOnceaccepts the string"true", not only the boolean.Not changed
Baileys
getChatHistoryremains unsupported by design; the adapter degrades gracefully (lazy is a no-op + the live message still posts; bulk skips the chat). Historical location/quote fidelity comes from the 0.8.6 engine enrichment — no adapter change needed.Tests
New: a failed history post is isolated and left unmarked while the rest post; the bulk sweep creates no conversation for a chat with no fetchable history. Full suite green (233 tests across all plugins),
tsc --noEmitclean, plugin packages, catalog up to date.