{"record":{"id":"ded8df1da524a62f","repo":"BigPizzaV3/CodexPlusPlus","slug":"http","errorCode":null,"errorMessage":"HTTP {}：{}","messagePattern":"HTTP (.+?)：(.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/sub2api.rs","lineNumber":67,"sourceCode":"    }\n    let api_key = profile.api_key.trim();\n    if api_key.is_empty() {\n        anyhow::bail!(\"API Key 不能为空\");\n    }\n\n    let endpoint = sub2api_billing_endpoint(base_url);\n    let client = crate::http_client::proxied_client(&profile.user_agent)?;\n    let response = client\n        .get(&endpoint)\n        .bearer_auth(api_key)\n        .header(\"x-api-key\", api_key)\n        .send()\n        .await\n        .with_context(|| format!(\"请求 {endpoint} 失败\"))?;\n    let status = response.status();\n    let body = response.text().await.unwrap_or_default();\n    if !status.is_success() {\n        anyhow::bail!(\n            \"HTTP {}：{}\",\n            status.as_u16(),\n            sub2api_error_message(&body).unwrap_or_else(|| \"上游拒绝读取倍率\".to_string())\n        );\n    }\n    let parsed: Sub2ApiBillingResponse =\n        serde_json::from_str(&body).context(\"倍率接口没有返回有效 JSON\")?;\n    validate_sub2api_billing_response(&parsed)?;\n    Ok(Sub2ApiBillingInfo {\n        endpoint,\n        group_rate_multiplier: parsed.group_rate_multiplier,\n        user_rate_multiplier: parsed.user_rate_multiplier,\n        resolved_rate_multiplier: parsed.resolved_rate_multiplier,\n        peak_rate_enabled: parsed.peak_rate_enabled,\n        peak_rate_multiplier: parsed.peak_rate_multiplier,\n        applied_peak_multiplier: parsed.applied_peak_multiplier,\n        effective_rate_multiplier: parsed.effective_rate_multiplier,\n        observed_at: parsed.observed_at,","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/sub2api.rs#L49-L85","documentation":"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).","triggerScenarios":"GET sub2api 计费端点返回 401/403/404/429/5xx 等非成功状态码。","commonSituations":"API Key 无效或被吊销（401/403）；Base URL 填错导致 404；倍率端点路径与上游版本不匹配；上游限流（429）或宕机（5xx）。","solutions":["根据状态码处理：401/403 更换或补全 API Key，404 核对 Base URL 与端点版本，429 降低请求频率","查看错误消息附带的响应体内容定位上游的具体错误描述","确认 sub2api 上游服务可用（浏览器直接访问该端点）"],"exampleFix":"// before\nlet response = client.get(&endpoint).send().await?;\n// after\nmatch client.get(&endpoint).send().await {\n    Ok(resp) if resp.status().is_success() => { /* ... */ }\n    Ok(resp) => eprintln!(\"倍率查询失败：HTTP {}\", resp.status()),\n    Err(e) => eprintln!(\"网络错误：{e}\"),\n}","handlingStrategy":"try-catch","validationCode":"// 先用低成本请求探测上游可达性\nlet probe = client.get(format!(\"{base}/api/status\")).send().await;\nif probe.is_err() { eprintln!(\"上游不可达，跳过倍率查询\"); return; }","typeGuard":null,"tryCatchPattern":"match fetch_sub2api_billing_info(&profile).await {\n    Err(e) if e.to_string().contains(\"HTTP 40\") => eprintln!(\"鉴权失败：{}，请检查 API Key\", e),\n    Err(e) if e.to_string().contains(\"HTTP 42\") => eprintln!(\"被限流，稍后重试：{}\", e),\n    Err(e) if e.to_string().contains(\"HTTP 5\") => eprintln!(\"上游故障，稍后重试：{}\", e),\n    Err(e) => eprintln!(\"倍率查询失败：{e}\"),\n    Ok(info) => { /* 使用 info */ }\n}","preventionTips":["Base URL 与端点版本保持一致，上游升级后及时核对","记录并展示上游返回的错误体辅助排障","对 5xx/429 实现指数退避重试"],"tags":["http","sub2api","billing","upstream"],"backgroundTag":"upstream-api-error","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}