{"record":{"id":"c5c0eee315531822","repo":"tonhowtf/omniget","slug":"n-o-achei","errorCode":null,"errorMessage":"não achei {}","messagePattern":"não achei (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/reddit/gdpr.rs","lineNumber":705,"sourceCode":"#[derive(Debug, Clone, Deserialize)]\npub struct Options {\n    /// O zip do export ou a pasta onde ele foi descompactado.\n    pub path: String,\n    /// Quando vem preenchido, grava o resumo aqui.\n    #[serde(default)]\n    pub export_dir: Option<String>,\n    /// \"json\", \"csv\", \"md\".\n    #[serde(default)]\n    pub formats: Vec<String>,\n    #[serde(default = \"def_top\")]\n    pub top: usize,\n}\n\npub fn run(opts: &Options, progress: &ProgressFn) -> Result<GdprResult> {\n    report(progress, ID, \"started\", 0, None, None);\n    let path = PathBuf::from(&opts.path);\n    if !path.exists() {\n        return Err(anyhow!(\"não achei {}\", opts.path));\n    }\n    let files = read_source(&path)?;\n    report(\n        progress,\n        ID,\n        \"progress\",\n        files.len() as u64,\n        Some(files.len() as u64),\n        Some(format!(\"{} arquivos\", files.len())),\n    );\n    let mut result = summarize(&files, &opts.path, opts.top);\n    if let Some(dir) = opts.export_dir.as_ref().filter(|d| !d.trim().is_empty()) {\n        let formats = if opts.formats.is_empty() {\n            vec![\"json\".to_string(), \"md\".to_string()]\n        } else {\n            opts.formats.clone()\n        };\n        result.exported = export(&result, Path::new(dir), &formats)?;","sourceCodeStart":687,"sourceCodeEnd":723,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/reddit/gdpr.rs#L687-L723","documentation":"GDPR export tool for Reddit archives validates that the user-supplied path exists before reading it. If `opts.path` does not resolve to an existing file or directory on disk, `run` aborts immediately with this Portuguese message via anyhow!. It is an up-front guard so the tool fails fast instead of erroring deeper in `read_source`.","triggerScenarios":"Calling `run(&Options{ path: ... }, progress)` where the path string points to a non-existent file/directory, contains a typo, uses a wrong relative path (wrong working directory), or the folder was moved/deleted before the call.","commonSituations":"User pasted a path with a trailing typo or spaces; ran the binary from a different CWD so a relative path no longer resolves; the GDPR ZIP downloaded from Reddit was renamed or deleted; path uses Windows backslashes in an unescaped Rust string.","solutions":["Check that the path exists before calling: `Path::new(&opts.path).exists()`","Pass an absolute path instead of a relative one","Verify the working directory of the process matches the assumption of the relative path","Confirm the user actually downloaded/extracted the Reddit GDPR export to that location"],"exampleFix":"// before\nlet opts = Options { path: \"~/Downloads/reddit\".into(), .. };\nrun(&opts, progress)?;\n// after\nlet expanded = shellexpand::tilde(\"~/Downloads/reddit\").to_string();\nassert!(Path::new(&expanded).exists(), \"GDPR path missing: {expanded}\");\nlet opts = Options { path: expanded, .. };\nrun(&opts, progress)?;","handlingStrategy":"validation","validationCode":"let p = PathBuf::from(&opts.path);\nif !p.exists() {\n    return Err(format!(\"GDPR path does not exist: {}\", opts.path));\n}\nif !p.is_dir() {\n    return Err(format!(\"GDPR path is not a directory: {}\", opts.path));\n}","typeGuard":"fn gdpr_path_is_valid(s: &str) -> bool {\n    let p = PathBuf::from(s);\n    p.exists() && (p.is_dir() || p.extension().map_or(false, |e| e == \"zip\"))\n}","tryCatchPattern":"match run(&opts, &progress) {\n    Ok(res) => println!(\"exported to {}\", res.zip_path),\n    Err(e) if e.to_string().starts_with(\"não achei\") => {\n        eprintln!(\"Path not found: {} — check the folder exists\", opts.path);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Always resolve user input to an absolute path (canonicalize) before passing it in","Validate path existence in the UI/CLI layer before invoking run()","Expand ~ and environment variables in user-supplied paths","Log the current working directory when using relative paths"],"tags":["filesystem","path","validation","input"],"backgroundTag":"file-not-found","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}