bug(storage): str_to_uint64 passes raw str to xxhash.xxh64, breaking all string-PK writes on python-xxhash >= 4
Summary
openviking/storage/vectordb/utils/str_to_uint64.py passes a raw str to xxhash.xxh64():
return xxhash.xxh64(input_string).intdigest()
python-xxhash >= 4.0.0 rejects str input with TypeError: Strings must be encoded before hashing (older versions, <= 3.8.1, silently hashed the string as UTF-8). With the default dependency constraint xxhash>=3.0.0 in uv.lock, fresh installs get 4.x and the bug is fatal.
Impact
The context collection schema uses a string primary key (collection_schemas.py: {"FieldName": "id", "FieldType": "string", "IsPrimaryKey": True}), and vikingdb_manager.py / collection_schemas.py force partial_update=True, so every upsert first reads the existing record:
upsert(partial_update=True)
-> adapter.get([id]) -> local_collection.fetch_data()
-> str_to_uint64(str(key)) -> xxh64(str) -> TypeError
-> except Exception -> 'Error reading existing record before partial update: ...'
-> returns '' -> write silently dropped
Result: all writes fail silently, collections stay empty, and downstream filtered counts log Aggregation results not available: extra_json is empty and return _total: 0. The bulk write path (local_collection.py _write_data_list) fails the same way.
Repro
import xxhash
xxhash.xxh64('abc') # TypeError with xxhash >= 4.0.0
Suggested fix (one line, behavior-identical to python-xxhash < 4)
return xxhash.xxh64(input_string.encode('utf-8')).intdigest()
Also note local_collection.py line ~637 catches only ValueError/OverflowError around str_to_uint64, so the TypeError propagates — worth catching too.
This report matches three open PRs that already encode string IDs before
xxhash.xxh64():
- #3971 is a one-file UTF-8 fix, and its discussion includes an additional Linux/aarch64 reproduction with xxhash 4.0.0.
- #3981 is another one-file variant that also accepts
bytesand usessurrogatepass; its submitted diff contains no tests and it currently has no GitHub checks. - #3995 keeps the production change to UTF-8 encoding and adds stable ASCII/Unicode hash assertions, a local string-primary-key CRUD regression, and the focused test to the cuVS CI job. All currently executed checks on that PR pass.
I will not open a fourth implementation for #4011 while these PRs remain active. Linking them here so reviewers can compare the existing patches and select which one should close this issue.
Confirming this is still reproducible on 0.4.14 (current PyPI latest, released before #3995 was merged), so fresh installs remain broken out of the box. A release including #3995 would be very welcome.
Environment: Debian 13, Python 3.11.16 (uv venv), xxhash 4.0.1, storage.vectordb.backend=local (default), pip install.
End-to-end symptom chain observed:
add_resourcewithwait=truereturns success —queue_statusshows Semantic/Embeddingprocessed>0, error_count=0/api/v1/search/findalways returnstotal: 0with HTTP 200 (no error surfaced)- Server log repeats
Error reading existing record before partial update: Strings must be encoded before hashingplusWARNING - Aggregation results not available: extra_json is empty
For the record, verified the trigger is the dependency range, not a specific openviking version: str_to_uint64.py is byte-identical across 0.4.11/0.4.13/0.4.14 and all of them declare xxhash>=3.0.0 with no upper bound. xxhash.xxh64('abc').intdigest() works on 3.8.1, raises TypeError on 4.0.1.
One operational note for anyone hitting this while waiting for the release: applying the one-line workaround (xxhash.xxh64(input_string.encode("utf-8"))) is not enough on an existing workspace — resources added under the broken path were never actually indexed (upserts silently dropped), so they need to be re-ingested after patching. With the patch + fresh re-ingest, search works normally here (relevant docs retrieved with sane scores).
This has been fixed on main by #3995.
The string primary key path now encodes IDs before passing them to xxhash.xxh64():
return xxhash.xxh64(input_string.encode("utf-8")).intdigest()
There are also regression tests covering stable ASCII/Unicode hashes, verifying that UTF-8 bytes are passed to xxhash, and round-tripping a local collection with string primary keys.
One operational note: versions released before this fix, such as 0.4.14, can still reproduce the issue with xxhash >= 4. Users hitting this should upgrade once a release containing #3995 is available. Any resources added while the broken path was active may need to be re-ingested because those writes were not actually indexed.