{"record":{"id":"14067f32d8a22853","repo":"bevyengine/bevy","slug":"the-length-of-the-list-of-values-values-len-wa","errorCode":null,"errorMessage":"The length of the list of values ({values_len}) was not divisible by that of the list of times ({times_len})","messagePattern":"The length of the list of values \\((.+?)\\) was not divisible by that of the list of times \\((.+?)\\)","errorType":"exception","errorClass":"ChunkedUnevenCoreError","httpStatus":null,"severity":"error","filePath":"crates/bevy_math/src/curve/cores.rs","lineNumber":510,"sourceCode":"    #[error(\n        \"Need at least two unique samples to create a ChunkedUnevenCore, but {samples} were provided\"\n    )]\n    NotEnoughSamples {\n        /// The number of samples that were provided.\n        samples: usize,\n    },\n\n    /// The length of the value buffer is supposed to be the `width` times the number of samples.\n    #[error(\"Expected {expected} total values based on width, but {actual} were provided\")]\n    MismatchedLengths {\n        /// The expected length of the value buffer.\n        expected: usize,\n        /// The actual length of the value buffer.\n        actual: usize,\n    },\n\n    /// Tried to infer the width, but the ratio of lengths wasn't an integer, so no such length exists.\n    #[error(\"The length of the list of values ({values_len}) was not divisible by that of the list of times ({times_len})\")]\n    NonDivisibleLengths {\n        /// The length of the value buffer.\n        values_len: usize,\n        /// The length of the time buffer.\n        times_len: usize,\n    },\n}\n\n#[cfg(feature = \"alloc\")]\nimpl<T> ChunkedUnevenCore<T> {\n    /// Create a new [`ChunkedUnevenCore`]. The given `times` are sorted, filtered to finite times,\n    /// and deduplicated. See the [type-level documentation] for more information about this type.\n    ///\n    /// Produces an error in any of the following circumstances:\n    /// - `width` is zero.\n    /// - `times` has less than `2` unique valid entries.\n    /// - `values` has the incorrect length relative to `times`.\n    ///","sourceCodeStart":492,"sourceCodeEnd":528,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_math/src/curve/cores.rs#L492-L528","documentation":"ChunkedUnevenCoreError::NonDivisibleLengths is returned only by ChunkedUnevenCore::new_width_inferred when values.len() is not an integer multiple of the processed (finite, sorted, deduplicated) times count. Width inference divides values length by times count; a non-divisible ratio means no consistent chunk size exists. `values_len`/`times_len` show the two lengths used.","triggerScenarios":"new_width_inferred(times, values) where values.len() % processed_times.len() != 0 — e.g. 7 values for 3 unique times, or values sized against raw times after dedup removed duplicates (4 values, 2 unique times is fine, but 6 values against 4 unique times is not).","commonSituations":"Flattened vector data whose dimension doesn't divide evenly (7 floats treated as 3D vectors plus a stray element); duplicate timestamps removed by the core making the raw ratio wrong; switching from new() to new_width_inferred without re-checking data assumptions.","solutions":["Use new_width_inferred only when you know values.len() == k * unique_finite_times_len for some integer k; otherwise call new() with the explicit width.","Validate divisibility at load time: `values.len() % unique_times != 0` -> reject the asset with a clear message.","Recount times the same way the core does: filter non-finite, sort, dedup, then compare."],"exampleFix":"// before\nlet times = vec![0.0, 0.0, 1.0, 2.0]; // 3 unique after dedup\nlet values = vec![1.0, 2.0, 3.0, 4.0]; // 4 not divisible by 3\nlet core = ChunkedUnevenCore::new_width_inferred(times, values)?; // NonDivisibleLengths { values_len: 4, times_len: 3 }\n\n// after\nlet times = vec![0.0, 0.0, 1.0, 2.0]; // 3 unique\nlet values = vec![1.0, 2.0, 3.0, 4.0, 5.0, 6.0]; // 6 = width 2 * 3\nlet core = ChunkedUnevenCore::new_width_inferred(times, values)?; // width inferred as 2","handlingStrategy":"validation","validationCode":"let mut t: Vec<f32> = times.iter().copied().filter(f32::is_finite).collect();\nt.sort_by(|a, b| a.total_cmp(b));\nt.dedup();\nif !t.is_empty() && values.len() % t.len() == 0 {\n    let core = ChunkedUnevenCore::new_width_inferred(times, values)?;\n} else {\n    // use new() with an explicit width instead\n}","typeGuard":null,"tryCatchPattern":"match ChunkedUnevenCore::new_width_inferred(times, values) {\n    Ok(core) => core,\n    Err(ChunkedUnevenCoreError::NonDivisibleLengths { values_len, times_len }) => {\n        warn!(\"{values_len} values not divisible by {times_len} unique times\");\n        return Ok(());\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Prefer the explicit-width new() constructor; use width inference only for trusted, pre-validated data.","Validate values.len() % unique_finite_times == 0 at asset load time.","Recompute the times list the same way the core does (filter, sort, dedup) before any length math."],"tags":["rust","bevy","math","curve","length-mismatch","runtime"],"backgroundTag":"values-not-divisible-by-times","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}