{"record":{"id":"ceaf09c20ec2e725","repo":"tinyhumansai/openhuman","slug":"chat-factory-failed-to-read-api-key-for-slug","errorCode":null,"errorMessage":"[chat-factory] failed to read API key for slug '{}': {}","messagePattern":"\\[chat-factory\\] failed to read API key for slug '(.+?)': (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/openhuman/inference/provider/factory.rs","lineNumber":2580,"sourceCode":"    }\n\n    let auth = AuthService::from_config(config);\n    // Try new-style key first.\n    let new_key = auth_key_for_slug(slug);\n    if let Ok(Some(k)) = auth.get_provider_bearer_token(&new_key, None) {\n        if !k.is_empty() {\n            log::debug!(\n                \"[providers][chat-factory] auth lookup slug={} key_present=true (new-style)\",\n                slug\n            );\n            return Ok(k);\n        }\n    }\n    // Fall back to legacy bare slug.\n    let key = auth\n        .get_provider_bearer_token(slug, None)\n        .map_err(|e| {\n            anyhow::anyhow!(\n                \"[chat-factory] failed to read API key for slug '{}': {}\",\n                slug,\n                e\n            )\n        })?\n        .unwrap_or_default();\n    if !key.is_empty() {\n        log::debug!(\n            \"[providers][chat-factory] auth lookup slug={} key_present=true\",\n            slug\n        );\n        return Ok(key);\n    }\n\n    // OAuth fallback for `openai` runs only after standard API-key resolution\n    // returns empty, so env/audit/metrics in the standard path always execute\n    // and the OAuth path never silently bypasses provider-agnostic logic.\n    if slug == \"openai\" {","sourceCodeStart":2562,"sourceCodeEnd":2598,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/src/openhuman/inference/provider/factory.rs#L2562-L2598","documentation":"Raised when keyring/auth-store lookup of the provider bearer token fails for both the new-style key and the legacy bare-slug key for a cloud provider slug; the new-style lookup returned empty/absent and the legacy fallback errored.","triggerScenarios":"Thrown at src/openhuman/inference/provider/factory.rs:2580 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-store the API key for the slug (settings or keyring command) so the auth lookup succeeds","Check the legacy error detail for a keyring backend problem (locked keychain, missing entry) and unlock/re-provision it"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}