{"record":{"id":"257430e86966d40e","repo":"tonhowtf/omniget","slug":"escolha-pelo-menos-um-formato-de-sa-da","errorCode":null,"errorMessage":"escolha pelo menos um formato de saída","messagePattern":"escolha pelo menos um formato de saída","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/reddit/thread.rs","lineNumber":968,"sourceCode":"    let base = base.trim().to_string();\n    let mut files = Vec::new();\n    if opts.markdown {\n        let path = out_path(&dest, &base, \"md\");\n        std::fs::write(&path, render_markdown(&thread))?;\n        files.push(path.to_string_lossy().to_string());\n    }\n    if opts.html {\n        let path = out_path(&dest, &base, \"html\");\n        std::fs::write(&path, render_html(&thread))?;\n        files.push(path.to_string_lossy().to_string());\n    }\n    if opts.json {\n        let path = out_path(&dest, &base, \"json\");\n        std::fs::write(&path, serde_json::to_string_pretty(&thread)?)?;\n        files.push(path.to_string_lossy().to_string());\n    }\n    if files.is_empty() {\n        return Err(anyhow!(\"escolha pelo menos um formato de saída\"));\n    }\n    report(\n        &progress,\n        ID,\n        \"done\",\n        total as u64,\n        Some(total as u64),\n        None,\n    );\n    Ok(ThreadResult {\n        title: thread.post.title,\n        subreddit: thread.post.subreddit,\n        author: thread.post.author,\n        permalink: thread.post.permalink,\n        comments: total,\n        missing,\n        requests: fetcher.requests(),\n        files,","sourceCodeStart":950,"sourceCodeEnd":986,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/reddit/thread.rs#L950-L986","documentation":"In run(), each enabled output format (json, txt/md, etc.) writes a file and pushes its path to `files`. If `files` is empty, no output format option was requested, so the tool aborts with this error rather than downloading the thread and producing nothing.","triggerScenarios":"Calling run() / baixa_uma_thread_publica_de_verdade with ThreadOptions where every format flag (opts.json, opts.txt, etc.) is false or omitted — validation happens after fetching but before the done report.","commonSituations":"Building options programmatically and forgetting to set any format flag; a config file defaulting all formats to false; UI passing only flags the user disabled.","solutions":["Set at least one format flag to true, e.g. opts.json = true","Validate the options before invoking the download to fail fast","If multiple formats are desired, enable each one explicitly (files are written per enabled format)"],"exampleFix":"// before\nlet opts = ThreadOptions { dest: Some(dir), ..Default::default() }; // no format flag\n// after\nlet opts = ThreadOptions { dest: Some(dir), json: true, ..Default::default() };","handlingStrategy":"validation","validationCode":"if !(opts.json || opts.txt || opts.md) {\n    return Err(anyhow!(\"pick at least one output format before downloading\"));\n}","typeGuard":null,"tryCatchPattern":"match run(&progress, opts).await {\n    Err(e) if e.to_string().contains(\"formato de saida\") => {\n        eprintln!(\"no output format selected; enable json/txt/md in options\");\n    }\n    Err(e) => return Err(e),\n    Ok(_) => {}\n}","preventionTips":["Always set at least one format flag in ThreadOptions","Validate options before starting the (potentially long) download","Provide a default format (e.g. json) in constructors/Default impls used by your app"],"tags":["reddit","options-validation","empty-output"],"backgroundTag":"missing-required-option","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}