BigPizzaV3/CodexPlusPlus · error · anyhow::Error

LLM Bridge 仅支持 POST 请求

Error message

LLM Bridge 仅支持 POST 请求

What it means

llm_proxy_value in the LLM Bridge HTTP handler only proxies POST requests. The method is read from the payload's "method" field (defaulting to "POST"), and any explicitly supplied non-POST method aborts the bridge call.

Solutions

  1. Change the request to POST (or omit the "method" field, which defaults to POST)
  2. Move non-POST operations outside the LLM Bridge
  3. If a downstream API needs another verb, wrap it server-side behind a POST endpoint

Example fix

// before
{ "method": "GET", "url": "https://api.example.com/v1/models", "body": "" }
// after
{ "method": "POST", "url": "https://api.example.com/v1/chat/completions", "body": "{\"model\":\"...\"}" }
Defensive patterns

Strategy: validation

Validate before calling

const BRIDGE_METHOD: &str = "POST";
fn bridge_payload(url: &str, body: &str) -> serde_json::Value {
    serde_json::json!({ "method": "POST", "url": url, "body": body })
}

Try / catch

match llm_proxy_value(payload).await {
    Err(e) if e.to_string().contains("仅支持 POST") => {
        payload["method"] = serde_json::json!("POST");
        retry(payload)
    }
    other => other,
}

Prevention

When it happens

Trigger: Sending a bridge request whose JSON payload contains "method": "GET"/"PUT"/"DELETE" (or any non-POST value) to llm_proxy_value via handle_bridge_request.

Common situations: Client reuses a generic proxy wrapper that forwards the original HTTP verb; a health-check probe sends GET through the bridge; typo like "post" is fine (case-insensitive) but "PATCH" is not.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/bd9e0d934db61521. Report an issue: GitHub.

Appendix: source

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

    let settings = crate::stepwise::settings_with_payload(result?, &payload);
    crate::stepwise::test_connection(&settings).await
}

async fn llm_proxy_value(payload: Value) -> anyhow::Result<Value> {
    let url = validate_llm_proxy_url(
        payload
            .get("url")
            .and_then(Value::as_str)
            .unwrap_or_default(),
    )?;
    let method = payload
        .get("method")
        .and_then(Value::as_str)
        .map(str::trim)
        .filter(|value| !value.is_empty())
        .unwrap_or("POST");
    if !method.eq_ignore_ascii_case("POST") {
        anyhow::bail!("LLM Bridge 仅支持 POST 请求");
    }

    let timeout_ms = payload
        .get("timeout_ms")
        .and_then(Value::as_u64)
        .unwrap_or(60_000)
        .clamp(1_000, 60_000);
    let body = payload
        .get("body")
        .and_then(Value::as_str)
        .unwrap_or_default()
        .to_string();
    if body.len() > 1_048_576 {
        anyhow::bail!("LLM Bridge 请求体过大");
    }

    let client = reqwest::Client::builder()
        .timeout(std::time::Duration::from_millis(timeout_ms))

View on GitHub (pinned to b1ed92e5e4)