slymnoyann/hey-1 · error · Error

Some attachments failed to upload

Error message

Some attachments failed to upload

What it means

Thrown in useUploadAttachments after uploadToIPFS returns fewer uploaded entries than the previewAttachments prepared for upload. The count mismatch means one or more files never made it through the IPFS pinning/upload service, so attaching them by index would misalign mimeTypes and uris.

Source

Thrown at src/hooks/useUploadAttachments.tsx:40

      setIsUploading(true);

      const files = Array.from(attachments);
      const compressedFiles = await compressFiles(files);

      if (!compressedFiles.every(validateFileSize)) {
        setIsUploading(false);
        return [];
      }

      const previewAttachments = createPreviewAttachments(compressedFiles);
      const attachmentIds = previewAttachments.map(({ id }) => id as string);

      addAttachments(previewAttachments);

      try {
        const uploaded = await uploadToIPFS(compressedFiles);
        if (uploaded.length !== previewAttachments.length) {
          throw new Error("Some attachments failed to upload");
        }

        const result = uploaded.map((file, index) => ({
          ...previewAttachments[index],
          mimeType: file.mimeType,
          uri: file.uri
        }));

        updateAttachments(result);
        setIsUploading(false);

        return result;
      } catch {
        toast.error("Something went wrong while uploading!");
        removeAttachments(attachmentIds);
        setIsUploading(false);
        return [];
      }

View on GitHub (pinned to 88c8f9d553)

Solutions

  1. Retry the failed upload (or only the missing files) — transient IPFS/service failures are the most common cause
  2. Inspect uploadToIPFS to confirm whether it swallows per-file errors; log which indices are missing instead of failing the whole batch
  3. Check service quota/rate limits and API key validity if failures are consistent
  4. Validate file sizes/types before upload so bad items are rejected up front with a clear message

Example fix

// before
const uploaded = await uploadToIPFS(compressedFiles);
if (uploaded.length !== previewAttachments.length) {
  throw new Error("Some attachments failed to upload");
}

// after: retry once, then report specifics
let uploaded = await uploadToIPFS(compressedFiles);
if (uploaded.length !== compressedFiles.length) {
  uploaded = await uploadToIPFS(compressedFiles);
}
if (uploaded.length !== compressedFiles.length) {
  throw new Error(`Only ${uploaded.length}/${compressedFiles.length} attachments uploaded`);
}
Defensive patterns

Strategy: retry

Validate before calling

const validFiles = compressedFiles.filter(
  (f) => f.file.size > 0 && f.file.type
);
if (validFiles.length !== compressedFiles.length) {
  // drop/reject invalid files before upload so counts can't mismatch silently
}

Type guard

const isUploadResultComplete = (
  uploaded: unknown[],
  expected: number
): uploaded is { uri: string; mimeType: string }[] =>
  uploaded.length === expected && uploaded.every((u) => Boolean(u && (u as any).uri));

Try / catch

try {
  await uploadAttachments(files);
} catch (e) {
  if (e instanceof Error && e.message === "Some attachments failed to upload") {
    await sleep(2000);
    return uploadAttachments(files); // one retry for transient IPFS failures
  }
  throw e;
}

Prevention

When it happens

Trigger: uploadToIPFS silently drops items on per-file failure (partial batch failure), the service returns 4xx/5xx for some files, a client-side size-limit rejection skips files, or a timeout aborts part of a parallel upload batch.

Common situations: Flaky IPFS gateway/pinning service (web3.storage, Pinata, etc.) during batch uploads; rate limits kicking in mid-batch; oversized images where compression fails and the item is skipped; API token quota exhausted after N uploads.

Related errors


AI-assisted analysis of slymnoyann/hey-1@88c8f9d553 (2026-08-28). Data as JSON: /api/errors/8dc8ff98e7be56c6. Report an issue: GitHub.