chatboxai/chatbox · warning · Error

pdf_password_protected

Error message

pdf_password_protected

What it means

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.

Source

Thrown at src/renderer/packages/pdf-parser.ts:104

          }

          pageTexts.push(pageText.trim())
        } finally {
          page.cleanup()
        }
      } catch {
        pageTexts.push('')
      }
    }

    if (pageTexts.every((text) => text === '')) {
      return ''
    }

    return pageTexts.map((text, i) => `${formatPdfPageMarker(i + 1)}\n\n${text}`).join('\n\n')
  } catch (error) {
    if (error instanceof Error && error.name === 'PasswordException') {
      throw new Error(LOCAL_PARSER_PDF_PASSWORD_PROTECTED_ERROR)
    }
    throw error
  } finally {
    await loadingTask.destroy()
  }
}

View on GitHub (pinned to 81571269ad)

Solutions

  1. Remove the password from the PDF (re-save without encryption) before attaching.
  2. Prompt the user for the password and use a parser that accepts credentials.
  3. Fall back to a server-side parser that supports password-protected PDFs if available.
Defensive patterns

Strategy: try-catch

Validate before calling

// Cannot detect password protection without attempting load.
// Best pre-check: prompt user if the PDF is known to be encrypted, or use a lightweight header scan.

Type guard

function isPdfPasswordException(e: unknown): boolean {
  return e instanceof Error && e.name === 'PasswordException'
}

Try / catch

try {
  await parsePdfFileLocally(file)
} catch (e) {
  if (e instanceof Error && e.message === LOCAL_PARSER_PDF_PASSWORD_PROTECTED_ERROR) {
    // prompt user for password or fall back to a parser that supports credentials
  }
}

Prevention

When it happens

Trigger: Loading an encrypted/password-protected PDF via pdfjs getDocument; pdfjs throws PasswordException during loadingTask.promise, which the try/catch converts into this stable error.

Common situations: 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.

Related errors


AI-assisted analysis of chatboxai/chatbox@81571269ad (2026-08-12). Data as JSON: /api/errors/800800becef92d7b. Report an issue: GitHub.