paperclipai/paperclip · error
attachment ${attachment.id} exceeded the ${maxBytes}-byte ca
Error message
attachment ${attachment.id} exceeded the ${maxBytes}-byte cap while reading What it means
While streaming attachment bytes from storage, the accumulated total exceeded the caller's maxBytes cap even though the recorded byteSize was within it (the record and object disagree, or the size changed). Reading aborts rather than exceed the limit.
Source
Thrown at server/src/services/plugin-host-services.ts:2612
const maxBytes = typeof params.maxBytes === "number" && params.maxBytes > 0 ? params.maxBytes : null;
if (maxBytes !== null && attachment.byteSize > maxBytes) {
throw new Error(
`attachment ${attachment.id} is ${attachment.byteSize} bytes, over the ${maxBytes}-byte cap`,
);
}
const object = await getStorageService().getObject(attachment.companyId, attachment.objectKey);
const chunks: Buffer[] = [];
let total = 0;
for await (const chunk of object.stream) {
const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
total += buf.length;
// Defense in depth: enforce the cap during streaming too, so a
// metadata/object size mismatch can never exceed the requested cap.
if (maxBytes !== null && total > maxBytes) {
object.stream.destroy();
throw new Error(`attachment ${attachment.id} exceeded the ${maxBytes}-byte cap while reading`);
}
chunks.push(buf);
}
const bytes = Buffer.concat(chunks);
await logPluginActivity({
companyId,
action: "issue.attachment.read",
entityType: "issue",
entityId: attachment.issueId,
details: {
attachmentId: attachment.id,
byteSize: bytes.length,
contentType: attachment.contentType,
},
});
return {View on GitHub (pinned to a7e689b3c3)
Solutions
- The attachment grew past the cap during streaming read. Re-send a smaller file, or compress/chunk the content so total bytes stay under the cap.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at server/src/services/plugin-host-services.ts:2603 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of paperclipai/paperclip@a7e689b3c3 (2026-08-18).
Data as JSON: /api/errors/0ed6e26153fe0a1e.
Report an issue: GitHub.