tinyhumansai/openhuman · error

[chat-factory] openai oauth lookup failed: {e}

Error message

[chat-factory] openai oauth lookup failed: {e}

What it means

The OpenAI OAuth bearer-token lookup (openai_oauth::lookup_openai_bearer_token) failed while resolving credentials for slug 'openai'. This path runs only after standard API-key resolution returned empty, so both the API key and the OAuth token are unavailable or the OAuth store itself errored.

Source

Thrown at src/openhuman/inference/provider/factory.rs:2609

        );
        return Ok(key);
    }

    // OAuth fallback for `openai` runs only after standard API-key resolution
    // returns empty, so env/audit/metrics in the standard path always execute
    // and the OAuth path never silently bypasses provider-agnostic logic.
    if slug == "openai" {
        match crate::openhuman::inference::openai_oauth::lookup_openai_bearer_token(config) {
            Ok(Some(token)) if !token.is_empty() => {
                log::debug!(
                    "[providers][chat-factory] auth lookup slug={} key_present=true (oauth)",
                    slug
                );
                return Ok(token);
            }
            Ok(_) => {}
            Err(e) => {
                return Err(anyhow::anyhow!(
                    "[chat-factory] openai oauth lookup failed: {e}"
                ));
            }
        }
    }

    // Fallback: read from top-level config.api_key (direct config.toml api_key).
    // This handles the case where a key was set in config.toml but not saved
    // through the UI into auth-profiles.json.
    //
    // Scoped to the legacy direct-inference provider only — the cloud-provider
    // slug whose endpoint matches `config.inference_url`. `config.api_key` was
    // historically paired with `inference_url` for direct endpoint routing, so
    // an unscoped fallback would leak this global key to any other provider
    // whose auth-profile lookup returned empty (cross-provider credential leak
    // flagged by CodeRabbit + maintainers on #2724).
    if legacy_inference_slug(config) == Some(slug) {
        if let Some(config_key) = config.api_key.as_ref() {

View on GitHub (pinned to 7491200858)

Solutions

  1. Sign in again via the OpenAI OAuth flow to refresh the stored token
  2. Provide an OpenAI API key through the standard credential path instead of OAuth
  3. Inspect the underlying error for an expired/missing token file or keyring failure
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at src/openhuman/inference/provider/factory.rs:2609 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tinyhumansai/openhuman@7491200858 (2026-08-17). Data as JSON: /api/errors/799bfcf616848b63. Report an issue: GitHub.