block/buzz · error · Error

Media upload failed.

Error message

Media upload failed.

What it means

Fallback branch of uploadMediaFile's error normalization: when the IPC rejection is neither an Error, a non-empty string, nor an object with a usable `message`, it throws the generic 'Media upload failed.' The real cause is unknowable from the thrown value alone.

Source

Thrown at desktop/src/shared/api/tauriMedia.ts:53

      "upload_media_bytes_raw",
      bytes,
      {
        headers,
      },
    );
  } catch (error) {
    if (error instanceof Error) throw error;
    if (typeof error === "string" && error.trim()) throw new Error(error);
    if (
      typeof error === "object" &&
      error !== null &&
      "message" in error &&
      typeof error.message === "string" &&
      error.message.trim()
    ) {
      throw new Error(error.message);
    }
    throw new Error("Media upload failed.");
  }
}

/** Stop the native HTTP request associated with a background media upload. */
export async function cancelMediaUpload(progressId: string): Promise<void> {
  await invokeTauri("cancel_media_upload", { progressId });
}

/** Release the renderer's cancellation ownership after an upload settles. */
export async function releaseMediaUpload(progressId: string): Promise<void> {
  await invokeTauri("release_media_upload", { progressId });
}

/**
 * Open a native single-file picker constrained to images and upload the
 * chosen file. Non-image files are rejected in Rust (via MIME sniffing)
 * before the bytes leave the client, so discarded/non-image selections never
 * reach the relay. Resolves to `null` when the user cancels the dialog.

View on GitHub (pinned to dad5a33865)

Solutions

  1. Check the native/Tauri logs (devtools console, system log) for the underlying failure around the upload time.
  2. Verify network connectivity and media server reachability from the device.
  3. Confirm the Tauri media plugin/command versions match the frontend invoke signature.
  4. Wrap invokeTauriRaw calls to log the raw rejection before normalization so future failures aren't opaque.

Example fix

// before
} catch (error) {
  throw new Error("Media upload failed.");
}
// after
} catch (error) {
  console.error("upload_media_bytes_raw rejection:", error);
  throw new Error(`Media upload failed: ${JSON.stringify(error)}`);
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!navigator.onLine) throw new Error('Offline: upload deferred');

Type guard

function isGenericUploadFailure(e: unknown): boolean { return e instanceof Error && e.message === 'Media upload failed.'; }

Try / catch

try { await uploadMediaFile(file); } catch (e) { if (isGenericUploadFailure(e)) showRetryDialog(file); else throw e; }

Prevention

When it happens

Trigger: upload_media_bytes_raw rejects with an empty string, null/undefined, a number, or an object without a message field — the native layer failed without a descriptive payload.

Common situations: Native HTTP stack crashing without text; unexpected plugin response shape; device offline with a terse rejection; progress IPC channel torn down mid-upload.

Related errors


AI-assisted analysis of block/buzz@dad5a33865 (2026-09-05). Data as JSON: /api/errors/73040d0f8c9860ba. Report an issue: GitHub.