From 84fcc161eaeddbd24f92294f5e5d0e777705c355 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Sat, 23 May 2026 20:38:24 -0400 Subject: [PATCH] fix: throw on non-OK response in downloadMedia (Fixes JAVASCRIPT-REACT-B) When the server returns a 4xx/5xx, downloadMedia was silently returning the error response body as a blob. decryptAttachment would then fail with a misleading 'Mismatched SHA-256 digest' instead of surfacing the real HTTP error. Now throws immediately so callers (useAsyncCallback) can show the correct error state. Co-Authored-By: Claude Sonnet 4.6 --- src/app/utils/matrix.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/utils/matrix.ts b/src/app/utils/matrix.ts index 9df0aed79..6cc26ae02 100644 --- a/src/app/utils/matrix.ts +++ b/src/app/utils/matrix.ts @@ -299,6 +299,7 @@ export const mxcUrlToHttp = ( export const downloadMedia = async (src: string): Promise => { // this request is authenticated by service worker const res = await fetch(src, { method: 'GET' }); + if (!res.ok) throw new Error(`Media download failed: ${res.status} ${res.statusText}`); const blob = await res.blob(); return blob; };