From 5877b531f9fbbc60447bcbc9a9296bbafa3f4c08 Mon Sep 17 00:00:00 2001 From: Eric Gullickson <16152721+ericgullickson@users.noreply.github.com> Date: Fri, 13 Feb 2026 21:27:40 -0600 Subject: [PATCH] fix: allow PDF uploads in backend OCR controller and service (refs #182) The backend SUPPORTED_IMAGE_TYPES set excluded application/pdf, returning 415 before the request ever reached the OCR microservice. Added PDF to the allowed types in both controller and service validation layers. Co-Authored-By: Claude Opus 4.6 --- backend/src/features/ocr/api/ocr.controller.ts | 7 ++++--- backend/src/features/ocr/domain/ocr.service.ts | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/src/features/ocr/api/ocr.controller.ts b/backend/src/features/ocr/api/ocr.controller.ts index 4da998c..18860a6 100644 --- a/backend/src/features/ocr/api/ocr.controller.ts +++ b/backend/src/features/ocr/api/ocr.controller.ts @@ -15,12 +15,13 @@ const SUPPORTED_TYPES = new Set([ 'application/pdf', ]); -/** Image-only MIME types for receipt extraction (no PDF) */ +/** Image-only MIME types for receipt extraction */ const SUPPORTED_IMAGE_TYPES = new Set([ 'image/jpeg', 'image/png', 'image/heic', 'image/heif', + 'application/pdf', ]); export class OcrController { @@ -268,7 +269,7 @@ export class OcrController { }); return reply.code(415).send({ error: 'Unsupported Media Type', - message: `Unsupported file type: ${contentType}. Supported: JPEG, PNG, HEIC`, + message: `Unsupported file type: ${contentType}. Supported: JPEG, PNG, HEIC, PDF`, }); } @@ -380,7 +381,7 @@ export class OcrController { }); return reply.code(415).send({ error: 'Unsupported Media Type', - message: `Unsupported file type: ${contentType}. Supported: JPEG, PNG, HEIC`, + message: `Unsupported file type: ${contentType}. Supported: JPEG, PNG, HEIC, PDF`, }); } diff --git a/backend/src/features/ocr/domain/ocr.service.ts b/backend/src/features/ocr/domain/ocr.service.ts index 30ef7e6..0f50af2 100644 --- a/backend/src/features/ocr/domain/ocr.service.ts +++ b/backend/src/features/ocr/domain/ocr.service.ts @@ -31,12 +31,13 @@ const SUPPORTED_TYPES = new Set([ 'application/pdf', ]); -/** Image-only MIME types for receipt extraction (no PDF) */ +/** MIME types for receipt extraction */ const SUPPORTED_IMAGE_TYPES = new Set([ 'image/jpeg', 'image/png', 'image/heic', 'image/heif', + 'application/pdf', ]); /**