{"record":{"id":"800800becef92d7b","repo":"chatboxai/chatbox","slug":"pdf-password-protected-800800","errorCode":null,"errorMessage":"pdf_password_protected","messagePattern":"pdf_password_protected","errorType":"error_code","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"src/renderer/packages/pdf-parser.ts","lineNumber":104,"sourceCode":"          }\n\n          pageTexts.push(pageText.trim())\n        } finally {\n          page.cleanup()\n        }\n      } catch {\n        pageTexts.push('')\n      }\n    }\n\n    if (pageTexts.every((text) => text === '')) {\n      return ''\n    }\n\n    return pageTexts.map((text, i) => `${formatPdfPageMarker(i + 1)}\\n\\n${text}`).join('\\n\\n')\n  } catch (error) {\n    if (error instanceof Error && error.name === 'PasswordException') {\n      throw new Error(LOCAL_PARSER_PDF_PASSWORD_PROTECTED_ERROR)\n    }\n    throw error\n  } finally {\n    await loadingTask.destroy()\n  }\n}\n","sourceCodeStart":86,"sourceCodeEnd":111,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/renderer/packages/pdf-parser.ts#L86-L111","documentation":"Thrown by parsePdfFileLocally() in the catch block when pdfjs raises a PasswordException (error.name === 'PasswordException'), rewrapped with the LOCAL_PARSER_PDF_PASSWORD_PROTECTED_ERROR sentinel. It signals that the PDF requires a password the local parser cannot supply, so the caller can prompt the user or fall back.","triggerScenarios":"Loading an encrypted/password-protected PDF via pdfjs getDocument; pdfjs throws PasswordException during loadingTask.promise, which the try/catch converts into this stable error.","commonSituations":"User attaches a secured/encrypted PDF; a bank statement or signed contract with owner-password protection; PDF encrypted with permissions but openable without password may still trip pdfjs depending on encryption type.","solutions":["Remove the password from the PDF (re-save without encryption) before attaching.","Prompt the user for the password and use a parser that accepts credentials.","Fall back to a server-side parser that supports password-protected PDFs if available."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Cannot detect password protection without attempting load.\n// Best pre-check: prompt user if the PDF is known to be encrypted, or use a lightweight header scan.","typeGuard":"function isPdfPasswordException(e: unknown): boolean {\n  return e instanceof Error && e.name === 'PasswordException'\n}","tryCatchPattern":"try {\n  await parsePdfFileLocally(file)\n} catch (e) {\n  if (e instanceof Error && e.message === LOCAL_PARSER_PDF_PASSWORD_PROTECTED_ERROR) {\n    // prompt user for password or fall back to a parser that supports credentials\n  }\n}","preventionTips":["Warn users that encrypted PDFs need decryption first.","Provide a fallback parser that accepts passwords.","Distinguish this sentinel from generic parse failures in the UI."],"tags":["pdf","parser","encryption","password"],"backgroundTag":null,"analyzedSha":"81571269addb6bafb589a920b2883f1e1e084fd1","analyzedAt":"2026-08-12T21:51:44.981Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}