openai/codex · error · anyhow::Error

reasoning item in payload

Error message

reasoning item in payload {} had non-array {key}

What it means

A reasoning item's `content` or `summary` key was present but not a JSON array (and content was not null), so per-entry part extraction cannot proceed.

Solutions

  1. Fix the payload so the affected key is an array of part objects or absent
  2. Validate the reasoning item shape before reduction
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at codex-rs/rollout-trace/src/reducer/conversation/normalize.rs:313 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/32bc57334e3dc348. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/rollout-trace/src/reducer/conversation/normalize.rs:313

    Content,
    Summary,
}

fn append_reasoning_parts(
    item: &Value,
    key: &str,
    kind: ReasoningPartKind,
    raw_payload: &RawPayloadRef,
    parts: &mut Vec<ConversationPart>,
) -> Result<()> {
    let Some(items) = item.get(key) else {
        return Ok(());
    };
    if matches!((kind, items), (ReasoningPartKind::Content, Value::Null)) {
        return Ok(());
    }
    let Some(items) = items.as_array() else {
        bail!(
            "reasoning item in payload {} had non-array {key}",
            raw_payload.raw_payload_id
        );
    };

    for content_item in items {
        let Some(item_type) = content_item.get("type").and_then(Value::as_str) else {
            bail!(
                "reasoning item in payload {} had {key} entry without string type",
                raw_payload.raw_payload_id
            );
        };
        let expected_type = match kind {
            ReasoningPartKind::Content => {
                if !matches!(item_type, "reasoning_text" | "text") {
                    bail!(
                        "reasoning item in payload {} had unsupported content type {item_type}",
                        raw_payload.raw_payload_id

View on GitHub (pinned to 339751715c)