BigPizzaV3/CodexPlusPlus · error · anyhow::Error
Base URL 不得包含用户名或密码
Error message
Base URL 不得包含用户名或密码
What it means
In validate_llm_proxy_url, after the HTTPS check, the URL's username() or password() being non-empty triggers this bail. Embedded credentials (user:pass@host) in the Base URL would leak secrets into logs and error messages, so such URLs are rejected.
Solutions
- Remove the userinfo portion of the URL and pass credentials via an Authorization header instead
- Use an API-key config field rather than embedding secrets in the Base URL
- If the endpoint truly requires basic auth, front it with a proxy that adds the header
Example fix
// before
let url = validate_llm_proxy_url("https://sk-abc123@api.example.com/v1")?;
// after
let url = validate_llm_proxy_url("https://api.example.com/v1")?;
// pass key via Authorization header separately Defensive patterns
Strategy: validation
Validate before calling
fn url_has_userinfo(raw: &str) -> bool {
reqwest::Url::parse(raw.trim()).map(|u| !u.username().is_empty() || u.password().is_some()).unwrap_or(false)
} // reject when true Prevention
- Keep credentials out of URLs; use header-based auth
- Lint config files for 'user:pass@' patterns in URLs
- Store API keys in dedicated config fields
When it happens
Trigger: Calling llm_proxy_value with a URL like "https://user:pass@api.example.com" — url.username() is non-empty or url.password() is Some.
Common situations: Copying a gateway URL that includes basic-auth credentials, or configuring an API key directly in the URL instead of the auth header.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- API 地址须使用 HTTPS,且不含账号、密码、查询参数或片段
- API 地址须使用 HTTPS,且不含账号、密码、查询参数或片段
- Base URL 不得指向本机或私有网络
- 仅支持 Codex++ 分享站点链接
- 主题市场资源地址越界
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/f0f3f9f40f7ff12d.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/routes.rs:790
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()
.trim_start_matches('[')
.trim_end_matches(']')
.to_lowercase();
if host.is_empty()
|| host == "localhost"View on GitHub (pinned to b1ed92e5e4)