{"record":{"id":"4b8a9668e53cd8d0","repo":"sigoden/aichat","slug":"aborted-4b8a96","errorCode":null,"errorMessage":"Aborted","messagePattern":"Aborted","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/rag/mod.rs","lineNumber":425,"sourceCode":"        for local_path in local_paths {\n            index += 1;\n            println!(\"Load {local_path} [{index}/{total}]\");\n            match load_file(&loaders, &local_path).await {\n                Ok(v) => loaded_documents.push(v),\n                Err(err) => handle_error(err, &mut has_error),\n            }\n        }\n\n        if has_error {\n            let mut aborted = true;\n            if *IS_STDOUT_TERMINAL && total > 0 {\n                let ans = Confirm::new(\"Some documents failed to load. Continue?\")\n                    .with_default(false)\n                    .prompt()?;\n                aborted = !ans;\n            }\n            if aborted {\n                bail!(\"Aborted\");\n            }\n        }\n\n        let mut rag_files = vec![];\n        for LoadedDocument {\n            path,\n            contents,\n            mut metadata,\n        } in loaded_documents\n        {\n            let hash = sha256(&contents);\n            if let Some(file_ids) = to_deleted.get_mut(&hash) {\n                if let Some((i, _)) = file_ids\n                    .iter()\n                    .enumerate()\n                    .find(|(_, v)| self.data.files[*v].path == path)\n                {\n                    if file_ids.len() == 1 {","sourceCodeStart":407,"sourceCodeEnd":443,"githubUrl":"https://github.com/sigoden/aichat/blob/82976d349ad97ac9aae0655ad631dace5e2a6385/src/rag/mod.rs#L407-L443","documentation":"`sync_documents` in the RAG module aborts itself with `bail!(\"Aborted\")` when the user answers 'No' to the interactive confirm prompt 'Some documents failed to load. Continue?'. It is an intentional, user-requested cancellation: not all documents could be loaded, and the user declined to proceed with a partial RAG sync. Callers like `refresh_document_paths` propagate this error up.","triggerScenarios":"Calling sync_documents/refresh_document_paths while at least one document fails to load (unreadable file, parse error, unsupported format) triggers a Confirm dialog; answering No (or accepting the default false with Enter) sets `aborted = true` and throws this error.","commonSituations":"A file in the documents directory was deleted or renamed after being indexed; a file has permissions preventing reading; a document uses a format the loader cannot parse; running non-interactively where the default 'No' is accepted; CI environments where confirm prompts auto-decline.","solutions":["Check which documents failed to load (the loader errors printed before the prompt) and fix or remove them from the documents directory","Answer 'Yes' at the prompt if a partial sync of the remaining documents is acceptable","Verify file permissions and formats for all files in the configured RAG documents directory","Run in an interactive terminal so the Confirm prompt can be answered deliberately"],"exampleFix":"// before: blindly refreshing and crashing on prompt decline\nrag.refresh_document_paths()?;\n// after: treat user-abort as non-fatal\nmatch rag.refresh_document_paths() {\n    Err(e) if e.to_string() == \"Aborted\" => println!(\"Sync cancelled by user\"),\n    other => other?,\n}","handlingStrategy":"try-catch","validationCode":"// pre-check all documents are loadable before sync\nfor path in &doc_paths {\n    if !path.exists() || std::fs::metadata(path).map(|m| m.is_file()).unwrap_or(false) == false {\n        eprintln!(\"Warning: document not readable: {}\", path.display());\n    }\n}","typeGuard":"fn is_aborted(err: &anyhow::Error) -> bool {\n    err.to_string() == \"Aborted\"\n}","tryCatchPattern":"match rag.refresh_document_paths() {\n    Err(e) if e.to_string() == \"Aborted\" => println!(\"Sync cancelled\"),\n    other => other?,\n}","preventionTips":["Fix or remove failing documents before syncing","Run in an interactive terminal so the confirm prompt is answerable","Log which documents failed to load before deciding to continue"],"tags":["rag","user-abort","documents"],"backgroundTag":"operation-aborted-by-user","analyzedSha":"82976d349ad97ac9aae0655ad631dace5e2a6385","analyzedAt":"2026-09-09T18:33:06.139Z","contentChangedAt":"2026-09-09T18:33:06.139Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}