tonhowtf/omniget · error

formato desconhecido

Error message

formato desconhecido: {}

What it means

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.

Solutions

  1. Use one of the supported format strings (check the match arms in export(); e.g. the opencode config format).
  2. Fix casing/typos — the match is exact string comparison.
  3. Read the error message: it echoes the unknown format value, so compare it against the accepted set.
  4. If a new format is needed, add a match arm generating that output in export().

Example fix

// before
export(ids, "claude_desktop")   // unsupported
// after
export(ids, "opencode")        // supported format
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED_FORMATS: &[&str] = &["opencode", /* other supported arms */];
if !SUPPORTED_FORMATS.contains(&format) {
    eprintln!("format '{}' not supported; use one of {:?}", format, SUPPORTED_FORMATS);
    return;
}

Type guard

fn is_supported_format(f: &str) -> bool {
    matches!(f, "opencode")
}

Try / catch

match export(&ids, format) {
    Ok(json) => save(json),
    Err(e) if e.to_string().starts_with("formato desconhecido") => {
        eprintln!("{} — accepted formats: opencode", e);
    }
    Err(e) => show_error(e),
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/be6de1ec66007468. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/ai_keys.rs:620

        }
        "opencode" => {
            let mut providers = serde_json::Map::new();
            for e in &list {
                let npm = match e.kind.as_str() {
                    "anthropic" => "@ai-sdk/anthropic",
                    "gemini" => "@ai-sdk/google",
                    "openai" => "@ai-sdk/openai",
                    _ => "@ai-sdk/openai-compatible",
                };
                let mut models = serde_json::Map::new();
                if !e.model.is_empty() {
                    models.insert(e.model.clone(), serde_json::json!({ "name": e.model }));
                }
                providers.insert(slug(&e.name), serde_json::json!({ "npm": npm, "name": e.name, "options": { "baseURL": e.base_url, "apiKey": e.key }, "models": models }));
            }
            serde_json::to_string_pretty(&serde_json::json!({ "$schema": "https://opencode.ai/config.json", "provider": providers }))?
        }
        _ => return Err(anyhow!("formato desconhecido: {}", format)),
    })
}

/// Usa esta chave como a IA do OmniGet (Ajustes → IA).
pub fn use_in_app(id: &str) -> anyhow::Result<()> {
    let e = get(id)?;
    use crate::core::ai::{self, AiProvider};
    match e.kind.as_str() {
        "openai" => {
            ai::set(AiProvider::Openai, e.model.clone(), String::new(), Some(e.key.clone()), None);
        }
        "anthropic" => {
            ai::set(AiProvider::Anthropic, e.model.clone(), String::new(), None, Some(e.key.clone()));
        }
        "gemini" => return Err(anyhow!("o chat do OmniGet fala OpenAI/Anthropic; use a rota OpenAI-compatível do Gemini (…/v1beta/openai) como personalizado")),
        _ => {
            ai::set(AiProvider::Local, e.model.clone(), e.base_url.clone(), Some(e.key.clone()), None);
        }

View on GitHub (pinned to 8600b91f42)