{"record":{"id":"d727972133f1ba05","repo":"janhq/jan","slug":"unsupportedfiletype","errorCode":"UnsupportedFileType","errorMessage":"Unsupported file type: {0}","messagePattern":"Unsupported file type: (.+?)","errorType":"error_code","errorClass":"RagError","httpStatus":null,"severity":"error","filePath":"src-tauri/plugins/tauri-plugin-rag/src/error.rs","lineNumber":8,"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/7205d770c1e097c3daf35a911176410e93bc5564/src-tauri/plugins/tauri-plugin-rag/src/error.rs#L1-L21","documentation":"RagError::UnsupportedFileType is raised when the RAG plugin is asked to ingest a document whose file type/extension is not among the supported parsers (displayed as \"Unsupported file type: {0}\" with the offending type). The plugin intentionally rejects unknown formats instead of guessing.","triggerScenarios":"Calling the RAG ingest API with files like .docx, .xlsx, images, or arbitrary binaries when only formats such as .pdf/.txt are supported.","commonSituations":"Users dropping unsupported files into an upload UI; batch-importing a folder containing mixed file types; filename extensions changed to disguise binary content.","solutions":["Check the file extension/MIME type against the plugin's supported list before calling ingest.","Convert the document to a supported format (e.g. export .docx to PDF or plain text) first.","Filter or skip unsupported files during batch ingestion with a clear user notice.","Extend the plugin's parser set if a new format is genuinely required."],"exampleFix":"// before: blind ingest\nfor f in files { rag.ingest(f)?; }\n\n// after\nconst SUPPORTED: [&str; 2] = [\"pdf\", \"txt\"];\nfor f in files {\n    let ext = f.extension().and_then(|e| e.to_str()).unwrap_or(\"\");\n    if !SUPPORTED.contains(&ext) {\n        eprintln!(\"skipping {f:?}: unsupported type .{ext}\");\n        continue;\n    }\n    rag.ingest(f)?;\n}","handlingStrategy":"validation","validationCode":"// Rust: check extension against supported set before ingest\nfn is_supported(path: &Path) -> bool {\n    matches!(path.extension().and_then(|e| e.to_str()), Some(\"pdf\") | Some(\"txt\"))\n}","typeGuard":"fn as_unsupported_type(err: &RagError) -> Option<&str> {\n    match err { RagError::UnsupportedFileType(t) => Some(t), _ => None }\n}","tryCatchPattern":"match rag.ingest(file) {\n    Err(RagError::UnsupportedFileType(t)) => {\n        notify_user(format!(\".{t} files are not supported; convert to PDF or TXT\"));\n    }\n    other => other?,\n}","preventionTips":["Filter uploads by extension/MIME at the UI layer before they reach the plugin.","Show users the list of accepted formats up front.","Convert unsupported documents (docx, etc.) to supported formats during import.","Ignore disguised extensions — verify actual file signatures when possible."],"tags":["rag","rust","file-types"],"backgroundTag":"unsupported-operation","analyzedSha":"7205d770c1e097c3daf35a911176410e93bc5564","analyzedAt":"2026-09-17T14:27:30.100Z","contentChangedAt":"2026-09-17T14:27:30.100Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}