redis/redis-py · error · DataError
Both vector and element must be provided
Error message
Both vector and element must be provided
What it means
Raised by VectorSetCommands.vadd when either vector is falsy (empty list or empty bytes) or element is falsy (empty string). VADD needs both a real vector and a non-empty element identifier. The check is 'not vector or not element', so a zero-length vector or blank element name is rejected before the command is sent.
Source
Thrown at redis/commands/vectorset/commands.py:141
If not provided, int8 quantization is used.
The options are:
- NOQUANT: No quantization
- BIN: Binary quantization
- Q8: Signed 8-bit quantization
``ef`` sets the exploration factor to use.
If not provided, the default exploration factor is used.
``attributes`` is a dictionary or json string that contains the attributes to set for the vector.
If not provided, no attributes are set.
``numlinks`` sets the number of links to create for the vector.
If not provided, the default number of links is used.
For more information, see https://redis.io/commands/vadd.
"""
if not vector or not element:
raise DataError("Both vector and element must be provided")
pieces = []
if reduce_dim:
pieces.extend(["REDUCE", reduce_dim])
values_pieces = []
if isinstance(vector, bytes):
values_pieces.extend(["FP32", vector])
else:
values_pieces.extend(["VALUES", len(vector)])
values_pieces.extend(vector)
pieces.extend(values_pieces)
pieces.append(element)
if cas:
pieces.append("CAS")
View on GitHub (pinned to da03cdc7e8)
Solutions
- Ensure the vector is non-empty: a list of floats or non-empty bytes of the right dimensionality.
- Ensure element is a non-empty string identifier.
- Validate embeddings upstream: if not vector: skip/log instead of calling vadd.
Example fix
// before
client.vadd('set', embedding, name) # embedding == []
// after
if embedding:
client.vadd('set', embedding, name or 'default') Defensive patterns
Strategy: validation
Validate before calling
def safe_vadd(client, key, vector, element, **kw):
if not vector or not element:
return None
return client.vadd(key, vector, element, **kw) Type guard
def vadd_inputs_valid(vector, element) -> bool:
return bool(vector) and bool(element) Try / catch
try:
client.vadd('set', vec, name)
except Exception as e:
if 'must be provided' in str(e):
pass # skip empty embeddings
else:
raise Prevention
- Validate embeddings are non-empty before calling vadd.
- Ensure element identifiers are non-empty strings.
- Log/skip on empty embedding rather than erroring.
When it happens
Trigger: client.vadd('set', [], 'elem') (empty vector), client.vadd('set', b'', 'elem') (empty bytes), or client.vadd('set', [1,2], '') (empty element name). Also when a computed vector came back empty from an embedding model.
Common situations: Embedding pipeline returned an empty vector (model failure, empty input text); generating element names from data that produced a blank; passing bytes that happened to be empty.
Related errors
- 'input' should be provided
- Invalid slot state: {state}
- genpass optionally accepts a bits argument, between 0 and 40
- ACL LOG count must be an integer
- XCFGSET requires at least one of idmp_duration or idmp_maxsi
AI-assisted analysis of redis/redis-py@da03cdc7e8 (2026-08-04).
Data as JSON: /data/errors/e97c562c7abe9a08.json.
Report an issue: GitHub.