Skip to content

fix: canonicalize sync media enqueue JIDs#244

Merged
dinakars777 merged 1 commit into
openclaw:mainfrom
Daniel1of1:sync-media-fix
May 16, 2026
Merged

fix: canonicalize sync media enqueue JIDs#244
dinakars777 merged 1 commit into
openclaw:mainfrom
Daniel1of1:sync-media-fix

Conversation

@Daniel1of1
Copy link
Copy Markdown
Contributor

fix: canonicalize sync media enqueue JIDs

Summary

Fixes background media downloads during sync --follow --download-media when live one-to-one messages arrive with an @lid chat JID.

Message storage canonicalizes incoming chat JIDs via canonicalStoreJID, so the DB row may be stored under the resolved phone-number JID (@s.whatsapp.net). The media download enqueue path previously used the raw live pm.Chat.String(), which could still be an @lid. The media worker then looked up the wrong (chat_jid, msg_id) and skipped the download because the row was not found.

This change queues media downloads using the same canonical chat JID used by message storage.

Test

Added regression coverage for a live @lid media message that resolves to a PN chat row. Pre-fix, the row is stored under the PN JID but the worker looks up the LID JID, leaving local_path empty. Post-fix, the media is downloaded and local_path is set.

go test ./internal/app -run TestSyncDownloadMediaCanonicalizesLIDChatBeforeEnqueue -count=1

Optional pre-fix failure check:

git checkout HEAD~1 -- internal/app/sync_events.go && go test ./internal/app -run TestSyncDownloadMediaCanonicalizesLIDChatBeforeEnqueue -count=1; git checkout HEAD -- internal/app/sync_events.go

Notes

Observed with sync --follow --download-media: live image messages were stored with media metadata, but local_path stayed empty. Manual media download --chat <pn-jid> --id <msg-id> worked immediately, confirming the metadata/download path was valid and the issue was the live enqueue lookup JID.

Live sync can receive one-to-one chats as @lid JIDs while message storage canonicalizes them to phone-number JIDs. Queue media downloads with the same canonical chat JID used for storage so the worker can find the just-stored row and mark local_path after downloading.

Add regression coverage for a live @lid media message resolving to a PN chat row.

Assisted-by: ChatGPT:gpt-5
@Daniel1of1 Daniel1of1 marked this pull request as ready for review May 15, 2026 21:30
@dinakars777 dinakars777 merged commit 4ece595 into openclaw:main May 16, 2026
5 checks passed
dinakars777 added a commit that referenced this pull request May 16, 2026
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