Skip to content

Commit d786d79

Browse files
authored
fix(api): enhance error handling for encrypted PDFs in NDA processing (#1966)
1 parent 2808706 commit d786d79

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

apps/api/src/trust-portal/nda-pdf.service.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,14 @@ By signing below, the Receiving Party agrees to be bound by the terms of this Ag
253253
try {
254254
pdfDoc = await PDFDocument.load(pdfBuffer);
255255
} catch (error) {
256-
if (error instanceof EncryptedPDFError) {
256+
// Check for encrypted PDF error - use name/message check as instanceof can fail across module boundaries
257+
const isEncryptedError =
258+
error instanceof EncryptedPDFError ||
259+
(error instanceof Error &&
260+
(error.name === 'EncryptedPDFError' ||
261+
error.message.includes('is encrypted')));
262+
263+
if (isEncryptedError) {
257264
// Encrypted PDF - return as-is without watermark
258265
// User already signed NDA for accountability, encrypted PDFs require password anyway
259266
this.logger.debug(

0 commit comments

Comments
 (0)