openai/codex · error · anyhow::Error

pet frame grid must cover spritesheet exactly: expected

Error message

pet frame grid must cover spritesheet exactly: expected {spritesheet_width}x{spritesheet_height}, got {total_width}x{total_height}

What it means

Geometry guard in validate_frame_spec: frame.width*columns and/or frame.height*rows (computed with checked mul) does not equal the actual spritesheet pixel dimensions. The declared grid must tile the image exactly; leftover or overflowing pixels mean the manifest doesn't match the PNG.

Solutions

  1. Adjust frame width/height or columns/rows in the manifest so the grid exactly covers the spritesheet resolution
  2. Re-export the spritesheet at the expected size or regenerate the manifest to match the current image
Defensive patterns

Strategy: validation

When it happens

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

Appendix: source

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

fn validate_frame_spec(
    frame: &FrameSpec,
    spritesheet_width: u32,
    spritesheet_height: u32,
) -> Result<usize> {
    if frame.width == 0 || frame.height == 0 || frame.columns == 0 || frame.rows == 0 {
        bail!("pet frame dimensions and grid counts must be non-zero");
    }

    let total_width = frame
        .width
        .checked_mul(frame.columns)
        .context("pet frame grid width overflow")?;
    let total_height = frame
        .height
        .checked_mul(frame.rows)
        .context("pet frame grid height overflow")?;
    if total_width != spritesheet_width || total_height != spritesheet_height {
        bail!(
            "pet frame grid must cover spritesheet exactly: expected {spritesheet_width}x{spritesheet_height}, got {total_width}x{total_height}"
        );
    }

    let frame_count = frame
        .columns
        .checked_mul(frame.rows)
        .context("pet frame count overflow")?;
    let frame_count = usize::try_from(frame_count).context("pet frame count does not fit usize")?;
    if frame_count > MAX_PET_FRAMES {
        bail!("pet frame count {frame_count} exceeds maximum {MAX_PET_FRAMES}");
    }
    Ok(frame_count)
}

fn custom_pet_cache_id(id: &str) -> String {
    format!("custom-{id}")
}

View on GitHub (pinned to 339751715c)