BigPizzaV3/CodexPlusPlus · error · anyhow::Error

{message}

Error message

{message}

What it means

After fetching the models list from the upstream /models endpoint, if the list comes back empty the function bails with the message returned by the upstream status payload (its 'message' field), falling back to '上游没有返回可用模型'. The thrown message is dynamic — it relays whatever the upstream API reported about why no models are available.

Solutions

  1. Inspect the thrown message: it is the upstream's own explanation (auth failure, rate limit, etc.) and fix accordingly.
  2. Verify the API key is valid and has access to the models list.
  3. Check the base URL points to a relay-compatible /v1/models endpoint.
  4. Retry later if the upstream is temporarily unavailable; check upstream service status.

Example fix

// before (server returned {"message":"Invalid API key"})
fetch_relay_profile_model_ids(&profile).await?; // bails: Invalid API key
// after
profile.api_key = valid_key.trim().to_string();
fetch_relay_profile_model_ids(&profile).await?;
Defensive patterns

Strategy: retry

Validate before calling

// Cannot be pre-validated locally; ensure config sanity first:
// !profile.upstream_base_url.trim().is_empty() && !profile.api_key.trim().is_empty()

Try / catch

match fetch_relay_profile_model_ids(&profile).await {
    Ok((models, endpoint)) => apply(models),
    Err(e) => {
        log::warn!("fetch models failed: {e}");
        if is_transient(&e.to_string()) { backoff_retry(|| fetch_relay_profile_model_ids(&profile), 3).await }
        else { ui.show_upstream_error(&e.to_string()); }
    }
}

Prevention

When it happens

Trigger: fetch_relay_profile_model_ids completes an HTTP request but fetch_models_from_source yields zero models — e.g. upstream returned an error status body with a message, an unexpected JSON shape, an empty data array, or a non-200 response whose payload contains 'message'.

Common situations: Wrong API key causing upstream auth error with a message; base URL pointing at a non-relay service returning unexpected JSON; upstream outage returning error JSON; relay has no models configured.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/7954d202397c3985. Report an issue: GitHub.

Appendix: source

Thrown at crates/codex-plus-core/src/model_catalog.rs:731

        base_url: if profile.upstream_base_url.trim().is_empty() {
            profile.base_url.trim().to_string()
        } else {
            profile.upstream_base_url.trim().to_string()
        },
        api_key: profile.api_key.trim().to_string(),
    };
    if source.base_url.is_empty() {
        anyhow::bail!("Base URL 不能为空");
    }
    let endpoint = models_endpoint(&source.base_url);
    let client = crate::http_client::proxied_client(&profile.user_agent)?;
    let (models, status) = fetch_models_from_source(&client, &source).await;
    if models.is_empty() {
        let message = status
            .get("message")
            .and_then(Value::as_str)
            .unwrap_or("上游没有返回可用模型");
        anyhow::bail!("{message}");
    }
    Ok((models, endpoint))
}

fn preferred_responses_api_status(sources: &[Value]) -> Value {
    let statuses = sources
        .iter()
        .filter_map(|source| source.get("responses_api"))
        .collect::<Vec<_>>();
    for wanted in ["unsupported", "supported", "failed"] {
        if let Some(status) = statuses
            .iter()
            .find(|status| status.get("status").and_then(Value::as_str) == Some(wanted))
        {
            return (*status).clone();
        }
    }
    responses_api_status("unknown", "", "")

View on GitHub (pinned to b1ed92e5e4)