BigPizzaV3/CodexPlusPlus · error
HTTP :
Error message
HTTP {}:{} What it means
The GET to the sub2api billing endpoint succeeded at transport level but returned a non-2xx status; the code bails with 'HTTP {status}: {body}'. The body text is embedded so the operator can see the relay's own error (invalid key, quota, upstream down).
Solutions
- 根据状态码处理:401/403 更换或补全 API Key,404 核对 Base URL 与端点版本,429 降低请求频率
- 查看错误消息附带的响应体内容定位上游的具体错误描述
- 确认 sub2api 上游服务可用(浏览器直接访问该端点)
Example fix
// before
let response = client.get(&endpoint).send().await?;
// after
match client.get(&endpoint).send().await {
Ok(resp) if resp.status().is_success() => { /* ... */ }
Ok(resp) => eprintln!("倍率查询失败:HTTP {}", resp.status()),
Err(e) => eprintln!("网络错误:{e}"),
} Defensive patterns
Strategy: try-catch
Validate before calling
// 先用低成本请求探测上游可达性
let probe = client.get(format!("{base}/api/status")).send().await;
if probe.is_err() { eprintln!("上游不可达,跳过倍率查询"); return; } Try / catch
match fetch_sub2api_billing_info(&profile).await {
Err(e) if e.to_string().contains("HTTP 40") => eprintln!("鉴权失败:{},请检查 API Key", e),
Err(e) if e.to_string().contains("HTTP 42") => eprintln!("被限流,稍后重试:{}", e),
Err(e) if e.to_string().contains("HTTP 5") => eprintln!("上游故障,稍后重试:{}", e),
Err(e) => eprintln!("倍率查询失败:{e}"),
Ok(info) => { /* 使用 info */ }
} Prevention
- Base URL 与端点版本保持一致,上游升级后及时核对
- 记录并展示上游返回的错误体辅助排障
- 对 5xx/429 实现指数退避重试
When it happens
Trigger: GET sub2api 计费端点返回 401/403/404/429/5xx 等非成功状态码。
Common situations: API Key 无效或被吊销(401/403);Base URL 填错导致 404;倍率端点路径与上游版本不匹配;上游限流(429)或宕机(5xx)。
Related errors
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/ded8df1da524a62f.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/sub2api.rs:67
}
let api_key = profile.api_key.trim();
if api_key.is_empty() {
anyhow::bail!("API Key 不能为空");
}
let endpoint = sub2api_billing_endpoint(base_url);
let client = crate::http_client::proxied_client(&profile.user_agent)?;
let response = client
.get(&endpoint)
.bearer_auth(api_key)
.header("x-api-key", api_key)
.send()
.await
.with_context(|| format!("请求 {endpoint} 失败"))?;
let status = response.status();
let body = response.text().await.unwrap_or_default();
if !status.is_success() {
anyhow::bail!(
"HTTP {}:{}",
status.as_u16(),
sub2api_error_message(&body).unwrap_or_else(|| "上游拒绝读取倍率".to_string())
);
}
let parsed: Sub2ApiBillingResponse =
serde_json::from_str(&body).context("倍率接口没有返回有效 JSON")?;
validate_sub2api_billing_response(&parsed)?;
Ok(Sub2ApiBillingInfo {
endpoint,
group_rate_multiplier: parsed.group_rate_multiplier,
user_rate_multiplier: parsed.user_rate_multiplier,
resolved_rate_multiplier: parsed.resolved_rate_multiplier,
peak_rate_enabled: parsed.peak_rate_enabled,
peak_rate_multiplier: parsed.peak_rate_multiplier,
applied_peak_multiplier: parsed.applied_peak_multiplier,
effective_rate_multiplier: parsed.effective_rate_multiplier,
observed_at: parsed.observed_at,View on GitHub (pinned to b1ed92e5e4)