Honor process attachment cap fallback

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-04-28 15:58:28 -05:00
1 parent 74a401bb6d
commit 708edc0887
2 files changed
+21 -5

No files matched your search

@@ -170,6 +170,25 @@ function makeAttachment(contentType: string, originalFilename: string) {
};
}
describe("normalizeIssueAttachmentMaxBytes", () => {
it("keeps the process-level attachment cap as the fallback for missing company limits", async () => {
const previous = process.env.PAPERCLIP_ATTACHMENT_MAX_BYTES;
process.env.PAPERCLIP_ATTACHMENT_MAX_BYTES = "5";
vi.resetModules();
try {
const { normalizeIssueAttachmentMaxBytes } = await import("../attachment-types.js");
expect(normalizeIssueAttachmentMaxBytes(null)).toBe(5);
} finally {
if (previous === undefined) {
delete process.env.PAPERCLIP_ATTACHMENT_MAX_BYTES;
} else {
process.env.PAPERCLIP_ATTACHMENT_MAX_BYTES = previous;
}
vi.resetModules();
}
});
});
describe("issue attachment routes", () => {
beforeEach(() => {
vi.resetModules();
+2 -5
View File
@@ -14,10 +14,7 @@
* - Exact types: "application/pdf"
* - Wildcards: "image/*" or "application/vnd.openxmlformats-officedocument.*"
*/
import {
DEFAULT_COMPANY_ATTACHMENT_MAX_BYTES,
MAX_COMPANY_ATTACHMENT_MAX_BYTES,
} from "@paperclipai/shared";
import { MAX_COMPANY_ATTACHMENT_MAX_BYTES } from "@paperclipai/shared";
export const DEFAULT_ALLOWED_TYPES: readonly string[] = [
"image/png",
@@ -99,7 +96,7 @@ export const MAX_ATTACHMENT_BYTES =
export function normalizeIssueAttachmentMaxBytes(value: number | null | undefined): number {
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
return DEFAULT_COMPANY_ATTACHMENT_MAX_BYTES;
return MAX_ATTACHMENT_BYTES;
}
return Math.min(Math.floor(value), MAX_COMPANY_ATTACHMENT_MAX_BYTES);
}