Skip to content

connector/directmedia: return not found when media ciphertext hash doesn't match - #1084

Open
indent[bot] wants to merge 1 commit into
mainfrom
indent/whatsapp-direct-media-hash-mismatch
Open

indent[bot] wants to merge 1 commit into
mainfrom
indent/whatsapp-direct-media-hash-mismatch

Conversation

@indent

@indent indent Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Logs

Failed to do media proxy with temp file 39,374 in 24 h (prev 0) since direct media was enabled. Loki sample (four 15-minute peak windows on 4 clusters): 3,988 lines failed to download media from last host: hash of media ciphertext doesn't match, across at least 5 accounts. In one 15-minute window, one account requested 1,287 distinct media, and 1,197 requests got HTTP 500. Android re-requested each failing media 7-23 times over about 220 s, and every attempt downloaded from all CDN hosts again.

Cause

makeDirectMediaResponse returns whatsmeow's ErrInvalidMediaEncSHA256 as a plain error, and the media proxy answers plain errors with 500 M_UNKNOWN, which clients treat as retryable. The reupload path already treats this error as a permanent failure.

Change

Return M_NOT_FOUND for a ciphertext hash mismatch so clients stop re-requesting media that won't download.

Before / after

Tested on a live account.

Case Base Head
Media whose stored ciphertext hash doesn't match the CDN blob (all hosts) 500 M_UNKNOWN (clients retry) 404 M_NOT_FOUND
Unaltered media in the same chat 200, correct bytes 200, identical bytes

View in Indent
Tag @indent to continue the conversation here.

@indent

indent Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Issues

No issues found.

CI Checks

All required CI checks passed on c98a44f.

Review agents

Select any unchecked box below to run or rerun that agent.

Passed (1)
  • Indent Review Agent · No issues found; hash mismatch now returns 404.
Full results

Indent Review Agent

  • Summary: No issues found; hash mismatch now returns 404.
  • Last ran on commit: c98a44fe
  • Latest result
    {
      "summary": "No issues found; hash mismatch now returns 404.",
      "findings": []
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant