{"record":{"id":"bff85e439f48bcc3","repo":"tonhowtf/omniget","slug":"formato-desconhecido-export","errorCode":null,"errorMessage":"formato desconhecido: {}","messagePattern":"formato desconhecido: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/x/export.rs","lineNumber":237,"sourceCode":"        t = html_escape(title),\n        b = body\n    )\n}\n\n/// Escreve `posts` em `dest` no formato pedido e devolve o caminho.\npub fn write_posts(\n    posts: &[XPost],\n    format: &str,\n    dest: &std::path::Path,\n    title: &str,\n) -> anyhow::Result<String> {\n    let content = match format {\n        \"json\" => serde_json::to_string_pretty(posts)?,\n        \"csv\" => posts_csv(posts),\n        \"md\" | \"markdown\" => posts_markdown(title, posts),\n        \"html\" => posts_html(title, posts),\n        \"txt\" | \"text\" => posts_text(posts),\n        other => anyhow::bail!(\"formato desconhecido: {}\", other),\n    };\n    if let Some(parent) = dest.parent() {\n        std::fs::create_dir_all(parent)?;\n    }\n    std::fs::write(dest, content)?;\n    Ok(dest.to_string_lossy().to_string())\n}\n\npub fn write_users(\n    users: &[XUser],\n    format: &str,\n    dest: &std::path::Path,\n) -> anyhow::Result<String> {\n    let content = match format {\n        \"json\" => serde_json::to_string_pretty(users)?,\n        \"csv\" => users_csv(users),\n        \"md\" | \"markdown\" | \"txt\" => {\n            users","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/x/export.rs#L219-L255","documentation":"write_posts in the X (Twitter) export module validates the `format` argument against a fixed set of accepted values: json, csv, md/markdown, html, txt/text. Any other string hits the catch-all arm and the function bails with this error before any file is written. It is a pure input-validation error — nothing was persisted to disk.","triggerScenarios":"Calling write_posts(posts, title, dest, format) with a format string outside the supported set, e.g. \"yaml\", \"JSON\" (uppercase, matching is exact), \"rtf\", or a typo like \"markdwon\".","commonSituations":"Passing a user-supplied format option straight from a CLI flag or config file without normalizing case/whitespace; assuming other formats (yaml, xml) are supported; capitalization mismatch since matching is case-sensitive.","solutions":["Use one of the supported format strings exactly: \"json\", \"csv\", \"md\", \"markdown\", \"html\", \"txt\", or \"text\".","Normalize the input first (trim and lowercase) before passing it to write_posts.","Validate the format at the CLI/config boundary with an enum or allowlist so invalid values are rejected early.","Check for typos in the format value; matching is exact and case-sensitive.","If a new format is genuinely needed, add a corresponding posts_<format> function and match arm in write_posts."],"exampleFix":"// before\nwrite_posts(&posts, title, dest, \"YAML\")?;\n// after\nlet fmt = format.trim().to_lowercase();\nmatch fmt.as_str() {\n    \"json\" | \"csv\" | \"md\" | \"markdown\" | \"html\" | \"txt\" | \"text\" => {}\n    other => panic!(\"unsupported format: {}\", other),\n}\nwrite_posts(&posts, title, dest, &fmt)?;","handlingStrategy":"validation","validationCode":"const FORMATS: [&str; 7] = [\"json\", \"csv\", \"md\", \"markdown\", \"html\", \"txt\", \"text\"];\nlet fmt = format.trim().to_lowercase();\nif !FORMATS.contains(&fmt.as_str()) {\n    anyhow::bail!(\"unsupported format: {} (use one of {:?})\", fmt, FORMATS);\n}","typeGuard":"fn is_supported_format(f: &str) -> bool {\n    matches!(f.trim().to_lowercase().as_str(), \"json\" | \"csv\" | \"md\" | \"markdown\" | \"html\" | \"txt\" | \"text\")\n}","tryCatchPattern":null,"preventionTips":["Model the format as an enum (serde/clap ValueEnum) instead of a free string.","Normalize case and whitespace of user-supplied format flags before dispatch.","Reject invalid formats at argument parsing time, not inside the export function.","Document the supported format list in CLI help."],"tags":["validation","export","argument","cli"],"backgroundTag":"invalid-enum-value","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"}