paperclipai/paperclip · warning

Image exceeds attachment bound

Error message

Image exceeds attachment bound

What it means

When downloading a Teams inline image, the runtime validates the response: result.data must exist, be an ArrayBuffer or ArrayBufferView, and not exceed MAX_ATTACHMENT_BYTES. Any violation throws 'Image exceeds attachment bound' (the message also fires when data is missing or of unexpected shape, since all three conditions share the throw). It guards memory against oversized or malformed attachment payloads.

Source

Thrown at server/src/services/chat-sdk-runtime.ts:2967

          const result = await Promise.race([
            http.get(teamsInlineImageDownloadUrl(locator), {
              responseType: "arraybuffer",
              maxRedirects: 0,
              maxContentLength: MAX_ATTACHMENT_BYTES,
              maxBodyLength: MAX_ATTACHMENT_BYTES,
              timeout: 10_000,
              signal,
            }),
            deadline,
          ]);
          signal.throwIfAborted();
          if (
            !result.data ||
            (!(result.data instanceof ArrayBuffer) &&
              !ArrayBuffer.isView(result.data)) ||
            result.data.byteLength > MAX_ATTACHMENT_BYTES
          )
            throw new Error("Image exceeds attachment bound");
          return Buffer.from(
            result.data instanceof ArrayBuffer
              ? new Uint8Array(result.data)
              : result.data,
          );
        } catch {
          throw new Error("Teams inline image download unavailable");
        } finally {
          clearTimeout(timer);
          signal.removeEventListener("abort", rejectDeadline);
        }
      };

      const attachment: Attachment = { ...metadata, fetchData: () => fetchData() };
      this.teamsInlineImageDescriptors.set(attachment, normalized);
      this.teamsInlineImageFetchers.set(attachment, fetchData);
      return attachment;
    }

View on GitHub (pinned to 01ad858492)

Solutions

  1. Lower the image size before sending it through Teams (compress/resize) so it fits MAX_ATTACHMENT_BYTES
  2. Raise MAX_ATTACHMENT_BYTES in configuration if the deployment policy allows larger attachments
  3. Verify the download URL returns binary data and not an error page; confirm the fetcher's auth is valid
  4. Handle the throw by replacing the attachment with a placeholder instead of failing the whole message

Example fix

// before
const buf = await runtime.fetchTeamsInlineImage(attachment, signal);
// after
let buf;
try {
  buf = await runtime.fetchTeamsInlineImage(attachment, signal);
} catch {
  buf = placeholderImageBuffer; // handle oversized/unavailable images gracefully
}
Defensive patterns

Strategy: try-catch

Validate before calling

// enforce a client-side cap before requesting
const MAX = MAX_ATTACHMENT_BYTES; // keep in sync with server bound

Try / catch

try { return await runtime.fetchTeamsInlineImage(attachment, signal); } catch (e) { if ((e as Error).message === 'Image exceeds attachment bound') return placeholderBuffer; throw e; }

Prevention

When it happens

Trigger: The Teams CDN/API returns image data larger than MAX_ATTACHMENT_BYTES, returns no data (falsy result.data), or returns a non-binary type that is neither ArrayBuffer nor ArrayBufferView.

Common situations: Users posting very large inline images in Teams; a Teams API change altering the response envelope so data lands in a different field; auth redirect returning HTML instead of binary (caught by the instanceof checks).

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


AI-assisted analysis of paperclipai/paperclip@01ad858492 (2026-09-10). Data as JSON: /api/errors/5488e012c16a12c9. Report an issue: GitHub.