TryFrom<PbIvf> for IvfModel has two ways to abort the process on a damaged index file instead of reporting it.
It asserts that the offsets and lengths vectors match in length (rust/lance-index/src/vector/ivf/storage.rs:235), and assert_eq! is compiled into release builds:
assertion `left == right` failed
left: 2
right: 3
The v1 centroid branch derives the centroid dimension by dividing the value count by the number of partition lengths (:209), which divides by zero when a file carries centroids and no lengths. Integer division by zero cannot be compiled out at all:
attempt to divide by zero
Both sit on the ordinary open path. IvfModel::try_from is what rust/lance/src/index/vector/ivf/v2.rs calls when opening a v3 IVF index, so any vector search over a damaged file takes it, and from Python it surfaces as a PanicException with no indication of which file was bad.
Nothing in Lance writes either shape: add_partition grows both vectors together and TryFrom<&IvfModel> for PbIvf copies both, so the trigger is a truncated, hand-edited, or foreign-written file rather than something a normal write can produce. That makes these read-side hardening items rather than bugs users hit through the API, but the failure mode is the wrong one for a parse boundary: rust/AGENTS.md maps format and integrity failures to Error::corrupt_file and reserves assert! for conditions that prevent data corruption.
TryFrom<PbIvf> for IvfModelhas two ways to abort the process on a damaged index file instead of reporting it.It asserts that the offsets and lengths vectors match in length (rust/lance-index/src/vector/ivf/storage.rs:235), and
assert_eq!is compiled into release builds:The v1 centroid branch derives the centroid dimension by dividing the value count by the number of partition lengths (:209), which divides by zero when a file carries centroids and no lengths. Integer division by zero cannot be compiled out at all:
Both sit on the ordinary open path.
IvfModel::try_fromis whatrust/lance/src/index/vector/ivf/v2.rscalls when opening a v3 IVF index, so any vector search over a damaged file takes it, and from Python it surfaces as aPanicExceptionwith no indication of which file was bad.Nothing in Lance writes either shape:
add_partitiongrows both vectors together andTryFrom<&IvfModel> for PbIvfcopies both, so the trigger is a truncated, hand-edited, or foreign-written file rather than something a normal write can produce. That makes these read-side hardening items rather than bugs users hit through the API, but the failure mode is the wrong one for a parse boundary:rust/AGENTS.mdmaps format and integrity failures toError::corrupt_fileand reservesassert!for conditions that prevent data corruption.