Skip to content

Error 404 when downloading authenticated media #377

@milad2golnia

Description

@milad2golnia

Describe the bug
When enable_authenticated_media is set to true in Synapse (the new default as of Synapse 1.120+), media uploaded to the server is only accessible via the authenticated endpoints (/_matrix/client/v1/media/download/...). However, the matrix-bot-sdk currently appears to request media from older endpoints like /_matrix/media/v3/download/..., which yields a 404 Not Found for newly uploaded “authenticated” media.

To Reproduce

  1. In Synapse’s homeserver.yaml, set enable_authenticated_media: true (or use a version of Synapse where it’s on by default).
  2. Start a bot using matrix-bot-sdk.
  3. Have a user upload an image or file to that server.
  4. The bot calls downloadContent() or uses mxcToHttp(), which tries the legacy endpoint /_matrix/media/v3/download/....
  5. Synapse returns 404 because the requested media is marked authenticated and no longer served on the old endpoint.

Expected behavior
Use the new /_matrix/client/v1/media/download/... endpoint automatically when requesting an authenticated media.

Log snippet
The bot receives 404 Not Found from Synapse when trying to download new media.

MatrixHttpClient (REQ-XX)
{
  "errcode": "M_NOT_FOUND",
  "error": "Not found"
}

Additional context
Refer to Synapse Docs for more information

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions