BigPizzaV3/CodexPlusPlus · error · anyhow::Error

倍率接口返回结构不是 sub2api.key_billing

Error message

倍率接口返回结构不是 sub2api.key_billing

What it means

Thrown by validate_sub2api_billing_response when the parsed response's envelope fields do not identify it as a sub2api token-scoped key_billing document: object != "sub2api.key_billing", schema_version != 1, or billing_scope != "token". The offending input is the JSON returned by the billing endpoint — it is structurally something else, so all multiplier fields are untrustworthy.

Source

Thrown at crates/codex-plus-core/src/sub2api.rs:108

    let cleaned = base_url.trim().trim_end_matches('/');
    if cleaned.is_empty() {
        return String::new();
    }
    if cleaned.ends_with("/sub2api/billing") {
        return cleaned.to_string();
    }
    if crate::protocol_proxy::has_version_suffix(cleaned) {
        return format!("{cleaned}/sub2api/billing");
    }
    format!("{cleaned}/v1/sub2api/billing")
}

fn validate_sub2api_billing_response(response: &Sub2ApiBillingResponse) -> anyhow::Result<()> {
    if response.object != "sub2api.key_billing"
        || response.schema_version != 1
        || response.billing_scope != "token"
    {
        anyhow::bail!("倍率接口返回结构不是 sub2api.key_billing");
    }
    for value in [
        response.group_rate_multiplier,
        response.resolved_rate_multiplier,
        response.effective_rate_multiplier,
    ] {
        if !value.is_finite() || value < 0.0 {
            anyhow::bail!("倍率接口返回了无效倍率");
        }
    }
    if let Some(value) = response.user_rate_multiplier {
        if !value.is_finite() || value < 0.0 {
            anyhow::bail!("倍率接口返回了无效用户倍率");
        }
    }
    if response.observed_at.trim().is_empty() {
        anyhow::bail!("倍率接口缺少观测时间");
    }

View on GitHub (pinned to f2074595a2)

Solutions

  1. 确认上游 sub2api 版本兼容该 schema
  2. 检查端点 URL 是否指向了其他接口
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/codex-plus-core/src/sub2api.rs:108 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/d0a33624656f3dc5. Report an issue: GitHub.