{"record":{"id":"a32e35365c18b208","repo":"janhq/jan","slug":"failed-to-parse-document-0","errorCode":null,"errorMessage":"Failed to parse document: {0}","messagePattern":"Failed to parse document: (.+?)","errorType":"error_code","errorClass":"RagError::ParseError","httpStatus":null,"severity":"warning","filePath":"src-tauri/plugins/tauri-plugin-rag/src/error.rs","lineNumber":5,"sourceCode":"use serde::{Deserialize, Serialize};\n\n#[derive(Debug, thiserror::Error, Serialize, Deserialize)]\npub enum RagError {\n    #[error(\"Failed to parse document: {0}\")]\n    ParseError(String),\n\n    #[error(\"Unsupported file type: {0}\")]\n    UnsupportedFileType(String),\n\n    #[error(\"IO error: {0}\")]\n    IoError(String),\n}\n\nimpl From<std::io::Error> for RagError {\n    fn from(err: std::io::Error) -> Self {\n        RagError::IoError(err.to_string())\n    }\n}\n\n","sourceCodeStart":1,"sourceCodeEnd":21,"githubUrl":"https://github.com/janhq/jan/blob/fad3f12a147d138388a66f0d92a02b2675f65294/src-tauri/plugins/tauri-plugin-rag/src/error.rs#L1-L21","documentation":"`RagError::ParseError(String)` is returned when a document fails to parse during RAG ingestion. The wrapped string describes the specific parser failure (PDF, DOCX, Markdown, etc.). It is the catch-all for any content-extraction problem that is not an I/O error or an unsupported file type.","triggerScenarios":"Feeding a corrupt or password-protected PDF to the PDF parser; a malformed DOCX/HTML structure the parser cannot walk; a Markdown file with broken encoding; any document whose bytes do not match the structure the chosen parser expects.","commonSituations":"Password-protected or DRMed PDFs; partially downloaded documents; scanned PDFs where text extraction yields nothing useful; documents produced by tools that emit non-standard markup; very large documents that hit a parser-internal limit.","solutions":["Read the wrapped string — it carries the parser-specific message (PDF parse error, encoding error, etc.).","For PDFs, confirm the file is not encrypted; if so, decrypt or skip it.","Re-open the file in its native application to confirm it is not corrupt.","If the file is legitimately unparseable, log it and continue ingestion of remaining documents rather than aborting the batch."],"exampleFix":"// before\nlet text = parse_pdf(&bytes)?;\n\n// after - per-file error isolation during batch ingest\nlet text = match parse_pdf(&bytes) {\n    Ok(t) => t,\n    Err(e) => {\n        tracing::warn!(\"skipping unparseable file {}: {e}\", path.display());\n        continue;\n    }\n};","handlingStrategy":"try-catch","validationCode":"fn looks_parseable(path: &Path) -> bool {\n    matches!(path.extension().and_then(|e| e.to_str()).map(str::to_lowercase).as_deref(),\n        Some(\"pdf\") | Some(\"docx\") | Some(\"md\") | Some(\"txt\") | Some(\"html\"))\n}","typeGuard":"null","tryCatchPattern":"match rag.ingest(&path).await {\n    Ok(doc) => Ok(doc),\n    Err(RagError::ParseError(msg)) => {\n        tracing::warn!(\"skipping unparseable file {}: {msg}\", path.display());\n        continue;\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Isolate per-file parse errors during batch ingestion so one bad file does not abort the batch.","Pre-filter files by supported extensions at the UI layer.","For PDFs, detect encryption up front and warn the user."],"tags":["rag","parsing","documents","tauri","rust"],"backgroundTag":null,"analyzedSha":"fad3f12a147d138388a66f0d92a02b2675f65294","analyzedAt":"2026-08-12T20:33:47.516Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}