fix: KeyError 'pq' when updating the quantizer on an HFresh vector index - #2147
Conversation
There was a problem hiding this comment.
Orca Security Scan Summary
| Status | Check | Issues by priority | |
|---|---|---|---|
| Infrastructure as Code | View in Orca | ||
| SAST | View in Orca | ||
| Secrets | View in Orca | ||
| Vulnerabilities | View in Orca |
There was a problem hiding this comment.
Pull request overview
Fixes a client-side KeyError: 'pq' raised when updating RQ quantizer settings on an HFresh vector index by making the quantizer-switch guard tolerant of schemas that don’t include pq (HFresh schemas may only contain an rq block). This aligns client behavior with server behavior and documented runtime mutability of rq.rescoreLimit.
Changes:
- Avoid direct subscripting of
vector_index_config["pq"]in the quantizer-switch guard; use a safe default whenpqis missing. - Add regression tests covering updating RQ on HFresh schemas without
pq/bq/sqblocks. - Add a test ensuring quantizer switching remains rejected on HNSW when PQ is enabled.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| weaviate/collections/classes/config.py | Makes quantizer-switch guard robust to missing pq block in vector index config (prevents KeyError). |
| test/collection/test_config_update.py | Adds regression tests for HFresh RQ updates without a pq block and keeps HNSW quantizer-switch rejection covered. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2147 +/- ##
==========================================
+ Coverage 86.64% 88.54% +1.89%
==========================================
Files 300 304 +4
Lines 23172 23486 +314
==========================================
+ Hits 20077 20795 +718
+ Misses 3095 2691 -404 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
You can't change the RQ settings on an HFresh index. Trying to update
rq.rescore_limitfails straight away withKeyError: 'pq', before the client even talks to the server. The docs say this setting can be changed at runtime, and the server does accept it if you edit the schema directly, so this is a client-side bug.The cause is in the check that stops you from switching quantizers. When you ask to update RQ, the client first looks at whether PQ, BQ or SQ are currently switched on, since swapping quantizer types means recreating the collection. That check assumes every index has all four quantizer blocks in its schema, which is true for HNSW. HFresh always uses RQ, so its schema only has an
rqblock, and looking uppqthrows.Adds tests covering the HFresh case, which fail without the fix, plus one pinning that switching quantizers on HNSW is still rejected. Verified against Weaviate 1.38.7, where
rq.rescore_limitnow updates as expected.