Skip to content

Fix empty vector panic#9070

Merged
timvisee merged 3 commits into
devfrom
fix-empty-vector-panic
May 19, 2026
Merged

Fix empty vector panic#9070
timvisee merged 3 commits into
devfrom
fix-empty-vector-panic

Conversation

@timvisee

Copy link
Copy Markdown
Member

Fixes #9045

Upserting an empty vector with wait=false can cause a panic. This fixes the problem by adding a validation rule and adds a test to assert behavior.

All Submissions:

  • My PR targets the dev branch (not master) and my branch was created from dev.
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

@timvisee timvisee merged commit ff4e41e into dev May 19, 2026
20 of 21 checks passed
@timvisee timvisee deleted the fix-empty-vector-panic branch May 19, 2026 13:21
generall pushed a commit that referenced this pull request May 22, 2026
* Add test

* Validate empty vector name

* Update test assertions
timvisee pushed a commit that referenced this pull request Jun 4, 2026
…9308)

`validate_multi_vector_len(N, &[])` with N > 0 previously returned Ok:
it passes the `vectors_count != 0` check, an empty `flatten_dense_vector`
clears the size check, and `0.is_multiple_of(N)` is true, so it falls into
the Ok branch. The unvalidated value then reaches
`convert_to_plain_multi_vector`, where `dim = data.len() / vectors_count = 0`,
the divisibility check `dim * vectors_count != data.len()` (0 == 0) passes,
and `data.into_iter().chunks(0)` panics (itertools asserts the chunk size is
non-zero). This is reachable from a single malformed gRPC Upsert via the
deprecated `vectors_count` field.

Add an `is_empty()` guard to `validate_multi_vector_len`, mirroring the
sibling `validate_multi_vector_by_length`, so empty flattened data is
rejected with a clear validation error before any conversion. Also add a
defensive `vectors_count == 0 || data.is_empty()` guard at the top of
`convert_to_plain_multi_vector`, which aligns it with the already-guarded
`MultiDenseVectorInternal::try_from_flatten` and closes the same panic on the
internal node-to-node `sync` path (where validation is log-only and
`SyncPoints.points` is not validated).

This completes the empty-vector hardening started in #9070, which covered the
REST side only and did not touch the gRPC flattened `vectors_count` form.

Includes a regression test covering both the rejected (empty) and accepted
(consistent multivector) cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants