openai/codex · error

Decode error for : ; content-type= ; body=

Error message

Decode error for {url}: {e}; content-type={ct}; body={body}

What it means

Error in decode_json (reached via exec_request_detailed callers): the HTTP request succeeded (2xx) but the response body could not be deserialized into the expected type. The message includes the URL, serde error, content-type, and body so mismatches between the API schema and the client structs are visible.

Solutions

  1. Compare the actual body in the message with the Rust struct and add/rename fields (serde attributes) to match
  2. If the endpoint serves HTML (auth wall/proxy), fix routing/auth so the JSON endpoint is reached
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at codex-rs/backend-client/src/client.rs:304 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/7007b752814e6b9d. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/backend-client/src/client.rs:304

            .to_string();
        let body = res.text().await.unwrap_or_default();
        if !status.is_success() {
            return Err(RequestError::UnexpectedStatus {
                method: method.to_string(),
                url: url.to_string(),
                status,
                content_type,
                body,
            });
        }
        Ok((body, content_type))
    }

    fn decode_json<T: DeserializeOwned>(&self, url: &str, ct: &str, body: &str) -> Result<T> {
        match serde_json::from_str::<T>(body) {
            Ok(v) => Ok(v),
            Err(e) => {
                anyhow::bail!("Decode error for {url}: {e}; content-type={ct}; body={body}");
            }
        }
    }

    pub async fn get_rate_limits(&self) -> Result<RateLimitSnapshot> {
        let snapshots = self.get_rate_limits_many().await?;
        let preferred = snapshots
            .iter()
            .find(|snapshot| snapshot.limit_id.as_deref() == Some("codex"))
            .cloned();
        Ok(preferred.unwrap_or_else(|| snapshots[0].clone()))
    }

    pub async fn get_rate_limits_many(&self) -> Result<Vec<RateLimitSnapshot>> {
        Ok(self.get_rate_limits_with_reset_credits().await?.rate_limits)
    }

    pub async fn get_accounts_check(&self) -> Result<AccountsCheckResponse> {

View on GitHub (pinned to 339751715c)