openai/codex · error · anyhow::Error

model item in payload

Error message

model item in payload {} did not contain a string type

What it means

Validation guard in normalize_model_item: a model-visible conversation item inside the recorded payload has no string "type" field (or a non-string one), so its kind cannot be determined. The malformed item JSON in the referenced raw payload is the input at fault.

Solutions

  1. Fix the producer serializing model items so every item includes a string type
  2. Inspect the raw payload to confirm which item is missing its type field
Defensive patterns

Strategy: validation

When it happens

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

Appendix: source

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

    Ok(normalized_items)
}

pub(super) fn token_usage_from_value(value: &Value) -> Option<TokenUsage> {
    Some(TokenUsage {
        input_tokens: u64_field(value, "input_tokens")?,
        cached_input_tokens: u64_field(value, "cached_input_tokens")?,
        cache_write_input_tokens: u64_field(value, "cache_write_input_tokens").unwrap_or(0),
        output_tokens: u64_field(value, "output_tokens")?,
        reasoning_output_tokens: u64_field(value, "reasoning_output_tokens")?,
    })
}

fn normalize_model_item(
    item: &Value,
    raw_payload: &RawPayloadRef,
) -> Result<NormalizedConversationItem> {
    let Some(item_type) = item.get("type").and_then(Value::as_str) else {
        bail!(
            "model item in payload {} did not contain a string type",
            raw_payload.raw_payload_id
        );
    };
    match item_type {
        "message" => normalize_message_item(item, raw_payload),
        "agent_message" => normalize_agent_message_item(item, raw_payload),
        "reasoning" => normalize_reasoning_item(item, raw_payload),
        "function_call" => Ok(NormalizedConversationItem {
            role: ConversationRole::Assistant,
            channel: Some(ConversationChannel::Commentary),
            kind: ConversationItemKind::FunctionCall,
            agent_message: None,
            body: raw_text_or_json_body(item.get("arguments"), raw_payload),
            call_id: item
                .get("call_id")
                .and_then(Value::as_str)
                .map(ToString::to_string),

View on GitHub (pinned to 339751715c)