bevyengine/bevy · error · ChunkedUnevenCoreError
Chunk width must be at least 1
Error message
Chunk width must be at least 1
What it means
ChunkedUnevenCoreError::ZeroWidth is returned by ChunkedUnevenCore::new when `width` is 0. The width is the number of values per sample time (the chunk size); zero would mean samples carry no data, and it also makes the values-length check meaningless (any length matches 0 times n). new_width_inferred can hit it too when values is empty.
Source
Thrown at crates/bevy_math/src/curve/cores.rs:488
///
/// # Invariants
/// This must always have a length of at least 2, be sorted, and have no duplicated or
/// non-finite times.
pub times: Vec<f32>,
/// The values that are used in sampling. Each width-worth of these correspond to a single sample.
///
/// # Invariants
/// The length of this vector must always be some fixed integer multiple of that of `times`.
pub values: Vec<T>,
}
/// An error that indicates that a [`ChunkedUnevenCore`] could not be formed.
#[derive(Debug, Error)]
#[error("Could not create a ChunkedUnevenCore")]
pub enum ChunkedUnevenCoreError {
/// The width of a `ChunkedUnevenCore` cannot be zero.
#[error("Chunk width must be at least 1")]
ZeroWidth,
/// At least two sample times are necessary to interpolate in `ChunkedUnevenCore`.
#[error(
"Need at least two unique samples to create a ChunkedUnevenCore, but {samples} were provided"
)]
NotEnoughSamples {
/// The number of samples that were provided.
samples: usize,
},
/// The length of the value buffer is supposed to be the `width` times the number of samples.
#[error("Expected {expected} total values based on width, but {actual} were provided")]
MismatchedLengths {
/// The expected length of the value buffer.
expected: usize,
/// The actual length of the value buffer.
actual: usize,View on GitHub (pinned to 396ca72708)
Solutions
- Pass width >= 1 — for vector samples it is the vector dimension.
- Fix the width computation: check `values.len()` against processed (filtered/deduped) times, not raw times, and guard the division.
- If values is legitimately empty, skip curve construction entirely.
Example fix
// before let width = values.len() / times.len(); // floors to 0 when len(times) > len(values) let core = ChunkedUnevenCore::new(times, values, width)?; // ZeroWidth // after let width = sample_dim; // known vector dimension, e.g. Vec3 => 3 let core = ChunkedUnevenCore::new(times, values, width)?;
Defensive patterns
Strategy: validation
Validate before calling
assert!(width >= 1, "chunk width must be at least 1");
if width >= 1 {
let core = ChunkedUnevenCore::new(times, values, width)?;
} Try / catch
let core = match ChunkedUnevenCore::new(times, values, width) {
Ok(core) => core,
Err(ChunkedUnevenCoreError::ZeroWidth) => {
ChunkedUnevenCore::new(times, values, 1)? // treat samples as scalars
}
Err(e) => return Err(e.into()),
}; Prevention
- Take width from the sample type's dimension (Vec2 => 2, Vec3 => 3) instead of deriving it by division.
- Guard any `values.len() / times.len()` computation against a zero result.
- Reject empty values buffers at asset load before attempting construction.
When it happens
Trigger: ChunkedUnevenCore::new(times, values, 0) — width often computed as values.len() / times.len() with integer division that floors to 0; new_width_inferred with an empty values list.
Common situations: Dynamically computing width from data whose sizes are mismatched; template/generic code where the sample dimension type is empty; asset loaders receiving an empty channel buffer.
Related errors
- Not enough data to build curve: needed at least {expected} c
- Could not construct an EvenCore
- Need at least two samples to create an EvenCore, but {sample
- Cannot create an EvenCore over an unbounded domain
- Could not construct an UnevenCore
AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20).
Data as JSON: /api/errors/4f5805d30056833d.
Report an issue: GitHub.