BigPizzaV3/CodexPlusPlus · error

Base URL 格式无效

Error message

Base URL 格式无效

What it means

validate_llm_proxy_url parses the user-supplied Base URL with reqwest::Url::parse and maps any parse failure to this error. It fires during LLM proxy configuration when the string is not a syntactically valid absolute URL (missing scheme, illegal characters, etc.), before the HTTPS and credential checks run.

Source

Thrown at crates/codex-plus-core/src/routes.rs:769

        .map(str::trim)
        .is_some_and(|value| value.eq_ignore_ascii_case("application/json"))
    {
        serde_json::from_slice::<Value>(&bytes).ok()
    } else {
        None
    };

    Ok(json!({
        "status": "ok",
        "http_status": http_status,
        "ok": ok,
        "body_text": body_text,
        "body_json": body_json,
    }))
}

fn validate_llm_proxy_url(raw: &str) -> anyhow::Result<reqwest::Url> {
    let url = reqwest::Url::parse(raw.trim()).map_err(|_| anyhow::anyhow!("Base URL 格式无效"))?;
    if url.scheme() != "https" {
        anyhow::bail!("Base URL 必须使用 HTTPS");
    }
    if !url.username().is_empty() || url.password().is_some() {
        anyhow::bail!("Base URL 不得包含用户名或密码");
    }
    let host = url
        .host_str()
        .ok_or_else(|| anyhow::anyhow!("Base URL 缺少主机名"))?;
    if is_blocked_llm_proxy_host(host) {
        anyhow::bail!("Base URL 不得指向本机或私有网络");
    }
    Ok(url)
}

fn is_blocked_llm_proxy_host(host: &str) -> bool {
    let host = host
        .trim()

View on GitHub (pinned to f2074595a2)

Solutions

  1. Include the scheme, e.g. https://api.example.com/v1
  2. Remove trailing spaces or stray characters from the URL
  3. Use a full absolute URL, not a host-only or relative string
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/codex-plus-core/src/routes.rs:769 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@f2074595a2 (2026-08-23). Data as JSON: /api/errors/e5884c49900ee1a9. Report an issue: GitHub.