Protect against None timestamps in Valkey layer (#6993)

Signed-off-by: Brennan Cathcart <brennancathcart@gmail.com>
This commit is contained in:
Brennan
2026-09-23 22:32:04 +05:30
committed by GitHub
parent 83b07b1537
commit 0cddc36d52
2 changed files with 31 additions and 15 deletions
+26
View File
@@ -158,6 +158,32 @@ def test_insert_handles_missing_created_at(valkey_db, mock_valkey_client):
assert "created_at" in kwargs["mapping"] # Should be added automatically
def test_insert_and_update_with_none_timestamps(valkey_db, mock_valkey_client):
"""Regression: a None timestamp must not crash insert() or update().
A None created_at falls back to now and a None updated_at is skipped, so
neither reaches fromisoformat() which only accepts a str.
"""
vector = np.random.rand(1536).tolist()
valkey_db.insert(
vectors=[vector],
payloads=[{"hash": "h", "data": "d", "created_at": None, "updated_at": None}],
ids=["id1"],
)
_, insert_kwargs = mock_valkey_client.hset.call_args
assert isinstance(insert_kwargs["mapping"]["created_at"], int)
valkey_db.update(
vector_id="id1",
vector=vector,
payload={"hash": "h", "data": "d", "created_at": None, "updated_at": None},
)
_, update_kwargs = mock_valkey_client.hset.call_args
assert isinstance(update_kwargs["mapping"]["created_at"], int)
assert "updated_at" not in update_kwargs["mapping"]
def test_delete(valkey_db, mock_valkey_client):
"""Test deleting a vector."""
# Call delete