tonhowtf/omniget · error
{msg}
Error message
{msg} What it means
In the test() function, when checking a key fails, the error message is captured, written into the key entry's state (last_ok=false, error field), and re-thrown as anyhow!(msg). The final message is whatever the underlying check produced — most commonly the HTTP error or JSON parse failure from the models/balance code path — so its content varies with the root cause.
Solutions
- Read the stored error text on the key entry (or the thrown message) to identify the root cause (auth vs network vs parse).
- Re-enter or rotate the API key if the message indicates 401/403.
- Correct the base_url if the message shows 404 or HTML output.
- Check network connectivity and provider status page for timeouts/5xx.
Example fix
null
Defensive patterns
Strategy: try-catch
Validate before calling
// verify the entry before testing
let entry = get(id)?;
if entry.key.is_empty() { eprintln!("key entry has no key stored"); }
if entry.base_url.is_empty() { eprintln!("key entry has no base_url"); } Type guard
fn is_testable(e: &KeyEntry) -> bool { !e.key.is_empty() && !e.base_url.is_empty() } Try / catch
match test(id) {
Ok(ok) => update_status(id, ok),
Err(e) => {
// test() already persisted err.to_string() on the entry; read e.error for the root cause
let stored = get(id).ok().and_then(|k| k.error);
diagnose(stored.as_deref().unwrap_or(&e.to_string()));
}
} Prevention
- Run test() after every key edit or rotation
- Read the entry's persisted error field to find the root cause
- Keep base_url and key fields validated at entry-creation time
- Check network before blaming the key
When it happens
Trigger: Calling test(id) on a key entry whose HTTP request fails (bad key, unreachable URL) or whose response cannot be parsed; the underlying error string is propagated verbatim.
Common situations: User clicks 'test key' in the UI with a revoked key, mistyped base_url, or offline network; stale entries whose provider endpoints changed.
Understand the failure class
Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.
Related errors
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/e6c340be3a7235c1.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/ai_keys.rs:406
pub async fn test(id: &str) -> anyhow::Result<KeyView> {
let entry = get(id)?;
let now = chrono::Utc::now().timestamp();
match models(&entry).await {
Ok(ids) => update(id, |e| {
e.last_ok = Some(true);
e.last_checked = Some(now);
e.models = ids.len();
e.error = None;
}),
Err(err) => {
let msg = err.to_string();
let _ = update(id, |e| {
e.last_ok = Some(false);
e.last_checked = Some(now);
e.error = Some(msg.clone());
});
Err(anyhow!(msg))
}
}
}
fn usd(v: f64) -> String {
if v.abs() < 0.01 {
format!("${:.4}", v)
} else {
format!("${:.2}", v)
}
}
pub async fn balance(id: &str) -> anyhow::Result<KeyView> {
let entry = get(id)?;
let c = client()?;
let text: String = match entry.kind.as_str() {
"openrouter" => {
let j: serde_json::Value = cView on GitHub (pinned to 8600b91f42)