block/buzz · error · Error

${error.message}

Error message

${error.message}

What it means

When the Tauri IPC rejection is an object carrying a non-empty string `message` field (common for serialized Rust/serde errors), uploadMediaFile rethrows new Error(error.message). The literal message is the backend-provided text.

Source

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

  try {
    return await invokeTauriRaw<BlobDescriptor>(
      "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)

View on GitHub (pinned to dad5a33865)

Solutions

  1. Inspect error.message for the underlying cause and address it (auth token, size limit, connectivity).
  2. Ensure the media server URL/config in the app settings is correct.
  3. Re-authenticate if the message indicates auth failure.
  4. Add size/type pre-validation to avoid server-side rejection.

Example fix

// before
catch (e) { alert('upload problem'); }
// after
catch (e) {
  const msg = e instanceof Error ? e.message : (e?.message ?? String(e));
  if (msg.includes('401')) await reauthAndRetry(); else throw new Error(msg);
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (file.size > MAX_UPLOAD_BYTES) throw new Error('File too large before upload');

Type guard

function hasMessage(e: unknown): e is { message: string } { return typeof e === 'object' && e !== null && 'message' in e && typeof (e as {message:unknown}).message === 'string'; }

Try / catch

try { await uploadMediaFile(file); } catch (e) { const msg = hasMessage(e) ? e.message : (e instanceof Error ? e.message : String(e)); handleError(msg); }

Prevention

When it happens

Trigger: upload_media_bytes_raw rejects with { message: "..." } — e.g. structured Tauri plugin errors, HTTP status errors from the native uploader, or serialized io::Error.

Common situations: Blossom/S3 media endpoint returning 401/413/500; native HTTP client connection errors; CDN rejecting the blob.

Related errors


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