openai/codex · error · anyhow::Error

animation references sprite index , but pet has frames

Error message

animation {name} references sprite index {}, but pet has {frame_count} frames

What it means

Generic index-range guard in validate_animation_indices: after animations (built-in defaults merged with custom specs) are assembled, any animation frame whose sprite_index is >= frame_count fails, meaning the sprite sheet lacks that frame. It is the safety net that also covers default animations, not just user specs.

Solutions

  1. Correct the animation's frame indices to reference existing sprites
  2. Ship a sprite sheet with at least the referenced frame count
  3. Remove or fix the offending animation entry (default or custom)
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at codex-rs/tui/src/pets/model.rs:464 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/8b91e7fa2d41b98b. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/tui/src/pets/model.rs:464

    animations
        .entry("idle".to_string())
        .or_insert_with(idle_animation);
    validate_animation_indices(&animations, frame_count)?;
    Ok(animations)
}

fn validate_animation_indices(
    animations: &HashMap<String, Animation>,
    frame_count: usize,
) -> Result<()> {
    for (name, animation) in animations {
        if animation.frames.is_empty() {
            bail!("animation {name} must include at least one frame");
        }
        for frame in &animation.frames {
            if frame.sprite_index >= frame_count {
                bail!(
                    "animation {name} references sprite index {}, but pet has {frame_count} frames",
                    frame.sprite_index
                );
            }
        }
        if !animations.contains_key(&animation.fallback) {
            bail!(
                "animation {name} fallback {} does not exist",
                animation.fallback
            );
        }
    }
    Ok(())
}

fn default_frame_count() -> usize {
    (catalog::DEFAULT_FRAME_COLUMNS * catalog::DEFAULT_FRAME_ROWS) as usize
}

View on GitHub (pinned to 339751715c)