Skip to content

[AI] fix: reject empty sparse vector name in CreateVectorName - #11743

Merged
timvisee merged 2 commits into
qdrant:devfrom
binnguyenx:fix/empty-sparse-vector-name
Nov 26, 2026
Merged

timvisee merged 2 commits into
qdrant:devfrom
binnguyenx:fix/empty-sparse-vector-name

Conversation

@binnguyenx

Copy link
Copy Markdown

Fixes #11722

Motivation

Currently, CreateVectorName allows empty sparse vector names even though sparse vectors are required to have a non-empty name. I wanted to fix this inconsistency and prevent invalid operations from reaching the cluster while preserving the existing behavior for unnamed dense vectors.

Change

Collection creation rejects a sparse vector named "" (#8194). The empty name belongs to the unnamed dense vector, and both would share one storage directory in a segment. Adding a vector to an existing collection (CreateVectorName) only ran the name format check, so it accepted a sparse "", reported Completed, and left a schema that the create API forbids.

  • Add CreateNamedVector::validate_vector_name() in collection_meta_ops.rs: the existing format check, plus "Sparse vector name cannot be empty" for sparse configs. The error message is the same as collection creation's.
  • Call it in do_create_vector_name (src/common/update.rs), the point that both REST and gRPC go through, so a bad request is rejected before anything is proposed to consensus.
  • Call it in plan_create_named_vector as well, in place of the format-only check, so committed entries that don't come through the API are rejected too. This mirrors how plan_create_collection calls validate_vector_names().

A dense vector named "" is still allowed: that's the normal unnamed vector, and the existing checks already handle it.

Note for review: like the existing name check in planning, this rejects a committed CreateNamedVector for a sparse "" that may already be in a consensus log from before this fix. Such an entry would now become a no-op on replay instead of registering the vector. I followed the existing pattern; tell me if you'd rather keep the planning check format-only.

Testing

  • New consensus test create_named_vector_reject_empty_name_sparse. It fails without the fix: the old code returns Ok(Plan { actions: [AddNamedVector { vector_name: "" .. }] }).
  • cargo nextest run -p storage: 382/382 pass.
  • cargo +nightly fmt --all and cargo clippy -p storage -p qdrant --all-targets -- -D warnings: clean.

AI disclosure

  • [AI] fix: reject empty sparse vector name in CreateVectorName

Prompt used (Claude Code): after asking it to find an unclaimed issue and explain it, the instruction was "comment on 11722 and start the fix", then "run the tests" and "continue" (commit and push). The investigation, the code change and this description were AI-generated. I reviewed the change and can answer questions about it.

🤖 Generated with Claude Code

Collection creation rejects a sparse vector named "" because that is the
name of the unnamed dense vector, and both would share one storage directory
in a segment (qdrant#8194). Adding a vector to an existing collection did not check
this, so CreateVectorName could register a sparse vector "" and report
success.

Add `CreateNamedVector::validate_vector_name`, which runs the existing name
format check plus the empty sparse name check, and call it both before the
operation is proposed (`do_create_vector_name`) and when consensus plans it,
as collection creation already does with `validate_vector_names`.

Fixes qdrant#11722

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

CreateNamedVector now provides vector-name validation. It rejects invalid names and rejects empty names for sparse vectors. The creation path uses this validator. Consensus planning uses it when all peers meet the version threshold and retains the previous validation for older or unknown peer versions. Tests cover both behaviors.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

  • qdrant/qdrant#11528: Adds consensus planning checks for invalid vector names, including empty sparse-vector names.

Suggested reviewers: ffuugoo, generall, timvisee

Merge Risk: Minimal · up to 924f3

Adding a sparse vector with an empty name is now rejected at the API. Consensus-level rejection waits until all peers are upgraded, so rolling upgrades stay safe. The empty name remains valid for the unnamed dense vector. No merge-blocking risk is evident.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: rejecting an empty sparse vector name in CreateVectorName. It matches the raw summary, which adds sparse-empty-name rejection to validate_vector_name and the create-ve…
Description check Passed The description states the problem (CreateVectorName accepting an empty sparse name), the fix (validate_vector_name, do_create_vector_name, plan_create_named_vector), the reason for keeping dense "" a…
Linked Issues check Passed Issue #11722 requires that gRPC Points/CreateVectorName with sparse vector name "" returns INVALID_ARGUMENT with "Sparse vector name cannot be empty" before a proposal is built, and that no "" sparse …
Out of Scope Changes check Passed All changed areas connect to #11722. collection_meta_ops.rs adds validate_vector_name(), which applies the shared sparse empty-name check, and the version constant REJECT_EMPTY_SPARSE_VECTOR_NAME_FROM…
Full details: Title check

Explanation

The title names the main change: rejecting an empty sparse vector name in CreateVectorName. It matches the raw summary, which adds sparse-empty-name rejection to validate_vector_name and the create-vector-name path. The "[AI]" prefix is noise, but the title still identifies the primary change.

Full details: Description check

Explanation

The description states the problem (CreateVectorName accepting an empty sparse name), the fix (validate_vector_name, do_create_vector_name, plan_create_named_vector), the reason for keeping dense "" allowed, a rolling-upgrade review note, and test results. It matches the changeset and the linked objectives.

Full details: Linked Issues check

Explanation

Issue #11722 requires that gRPC Points/CreateVectorName with sparse vector name "" returns INVALID_ARGUMENT with "Sparse vector name cannot be empty" before a proposal is built, and that no "" sparse vector enters the collection config. Per the change summary, src/common/update.rs (do_create_vector_name) now calls CreateNamedVector::validate_vector_name() before consensus submission. That method rejects an empty sparse name with the same message used by collection creation. The REST and gRPC paths both use this function, so the API requirement is met. A dense "" remains allowed, so the unnamed dense vector is unaffected. The new consensus test create_named_vector_reject_empty_name_sparse covers the planning path. The planning check in plan_create_named_vector is now gated by all_peers_at_version(1.20.3-dev). This gate does not weaken the API requirement, but a committed "" entry from an older peer can still apply during a rolling upgrade. The issue does not require planning-time rejection, so this is not a failing gap. Limits: the diff and file bodies were not read directly. The result relies on the change summary and the PR description.

Full details: Out of Scope Changes check

Explanation

All changed areas connect to #11722. collection_meta_ops.rs adds validate_vector_name(), which applies the shared sparse empty-name check, and the version constant REJECT_EMPTY_SPARSE_VECTOR_NAME_FROM_VERSION. The constant supports the version-gated planning check. src/common/update.rs moves validation ahead of the proposal. plan.rs applies the check during planning. The tests cover the sparse empty-name cases across peer-version configurations and the invalid-name case. The version gate is a compatibility measure stated in the PR objectives, so it is connected work. No unrelated changes appear in the summary. Limits: diff-level confirmation was not performed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b33cd449-3070-41eb-a2ba-647faeebcfd9
Commits

Reviewing files that changed from the base of the PR and between 5abd07b and 924f386.

Files selected for processing: 3

  • lib/storage/src/content_manager/collection_meta_ops.rs
  • lib/storage/src/content_manager/consensus_state_machine/state/plan.rs
  • lib/storage/src/content_manager/consensus_state_machine/tests/ops/named_vector.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

…ions

Peers before this fix accept and apply a committed CreateNamedVector for a
sparse vector named "". If upgraded peers rejected the same entry, a rolling
upgrade (or a new peer replaying the log tail) could leave peers with
different collection configs.

Only reject the empty sparse name in `plan_create_named_vector` once
`all_peers_at_version(1.20.3-dev)`; until then keep the format-only check
that older peers also run. The API check in `do_create_vector_name` stays
unconditional, since it rejects before anything is proposed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@timvisee timvisee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made some change to make this new behavior version specific. We need to do that to make sure the decision remains stable during a rolling upgrade, where nodes run different versions.

Thanks for your contribution!

@timvisee
timvisee merged commit 2bbbd7f into qdrant:dev Nov 26, 2026
32 checks passed
@binnguyenx

Copy link
Copy Markdown
Author

Thanks for the review and for adding the version gate. I hadn't considered rolling upgrades, and I'll keep it in mind for future consensus changes.

@binnguyenx
binnguyenx deleted the fix/empty-sparse-vector-name branch November 26, 2026 15:32
binnguyenx added a commit to binnguyenx/binnguyenx that referenced this pull request Nov 28, 2026
* docs: refocus profile on AI agents, infra and open source

Rewrite the intro around AI agents, infra and open source, mark
Viettel Solutions as past experience, and add an Open Source section
listing merged upstream contributions (qdrant/qdrant#11743).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: add Projects section featuring Cranial

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: add Python, TypeScript, FastAPI, LangGraph and AWS badges

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants