{"record":{"id":"be6de1ec66007468","repo":"tonhowtf/omniget","slug":"formato-desconhecido-ai-keys","errorCode":null,"errorMessage":"formato desconhecido: {}","messagePattern":"formato desconhecido: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/ai_keys.rs","lineNumber":620,"sourceCode":"        }\n        \"opencode\" => {\n            let mut providers = serde_json::Map::new();\n            for e in &list {\n                let npm = match e.kind.as_str() {\n                    \"anthropic\" => \"@ai-sdk/anthropic\",\n                    \"gemini\" => \"@ai-sdk/google\",\n                    \"openai\" => \"@ai-sdk/openai\",\n                    _ => \"@ai-sdk/openai-compatible\",\n                };\n                let mut models = serde_json::Map::new();\n                if !e.model.is_empty() {\n                    models.insert(e.model.clone(), serde_json::json!({ \"name\": e.model }));\n                }\n                providers.insert(slug(&e.name), serde_json::json!({ \"npm\": npm, \"name\": e.name, \"options\": { \"baseURL\": e.base_url, \"apiKey\": e.key }, \"models\": models }));\n            }\n            serde_json::to_string_pretty(&serde_json::json!({ \"$schema\": \"https://opencode.ai/config.json\", \"provider\": providers }))?\n        }\n        _ => return Err(anyhow!(\"formato desconhecido: {}\", format)),\n    })\n}\n\n/// Usa esta chave como a IA do OmniGet (Ajustes → IA).\npub fn use_in_app(id: &str) -> anyhow::Result<()> {\n    let e = get(id)?;\n    use crate::core::ai::{self, AiProvider};\n    match e.kind.as_str() {\n        \"openai\" => {\n            ai::set(AiProvider::Openai, e.model.clone(), String::new(), Some(e.key.clone()), None);\n        }\n        \"anthropic\" => {\n            ai::set(AiProvider::Anthropic, e.model.clone(), String::new(), None, Some(e.key.clone()));\n        }\n        \"gemini\" => return Err(anyhow!(\"o chat do OmniGet fala OpenAI/Anthropic; use a rota OpenAI-compatível do Gemini (…/v1beta/openai) como personalizado\")),\n        _ => {\n            ai::set(AiProvider::Local, e.model.clone(), e.base_url.clone(), Some(e.key.clone()), None);\n        }","sourceCodeStart":602,"sourceCodeEnd":638,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/ai_keys.rs#L602-L638","documentation":"export() supports a fixed set of output formats (e.g. opencode config JSON, etc.); an unrecognized format string hits the catch-all arm and throws 'formato desconhecido: {}'. This is input validation on the format parameter.","triggerScenarios":"Calling export(ids, format) with a format value not among the supported arms — typos like 'openCode', unsupported values like 'jsonl' or 'env', or format strings from an older/newer API version.","commonSituations":"Custom scripts or plugins passing their own format names; API version drift where a format was renamed; user typo in a CLI/script invoking the export command.","solutions":["Use one of the supported format strings (check the match arms in export(); e.g. the opencode config format).","Fix casing/typos — the match is exact string comparison.","Read the error message: it echoes the unknown format value, so compare it against the accepted set.","If a new format is needed, add a match arm generating that output in export()."],"exampleFix":"// before\nexport(ids, \"claude_desktop\")   // unsupported\n// after\nexport(ids, \"opencode\")        // supported format","handlingStrategy":"validation","validationCode":"const SUPPORTED_FORMATS: &[&str] = &[\"opencode\", /* other supported arms */];\nif !SUPPORTED_FORMATS.contains(&format) {\n    eprintln!(\"format '{}' not supported; use one of {:?}\", format, SUPPORTED_FORMATS);\n    return;\n}","typeGuard":"fn is_supported_format(f: &str) -> bool {\n    matches!(f, \"opencode\")\n}","tryCatchPattern":"match export(&ids, format) {\n    Ok(json) => save(json),\n    Err(e) if e.to_string().starts_with(\"formato desconhecido\") => {\n        eprintln!(\"{} — accepted formats: opencode\", e);\n    }\n    Err(e) => show_error(e),\n}","preventionTips":["Keep format names centralized in a shared enum/const list","Compare the echoed format in the error against the accepted set","Avoid free-text format inputs in scripts; use dropdowns/enums","Add tests covering each supported format string"],"tags":["invalid-argument","export","validation"],"backgroundTag":"invalid-argument-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"}