fix(vector): address PR review round 17 + local-mode collection-creation regression

Round 17 reviewer (🟡 Important):

1. docs/configuration.md degraded-migration runbook said `doc_id backfill
   failed on …` but the actual log line in qdrant_client.py:415 is
   `doc_id backfill scroll failed on …`. Operators grepping the runbook
   string would have missed it. Insert the `scroll` qualifier.

2. _create_one_payload_index returned True on the 400 schema-conflict
   path, so a wrong-type index discovered at create time skipped the
   consolidated `Payload index creation incomplete` summary — but a
   wrong-type index discovered via the existing-schema check at line
   195-206 did fire it. Tenants whose payload_schema is hidden from
   their JWT (Qdrant Cloud collection-scoped tokens) only ever observe
   the create-time path, so they never saw the operator-level summary.
   Return False so the summary fires in both cases.

3. docs/configuration.md said the upgrade-time delay was `proportional to
   point count while writes are issued` — overstating the cost. Writes
   are proportional to int-typed points only; the scroll itself is
   proportional to total point count. Reword.

Local-mode collection-creation regression (root-cause of failing
single-user / login-flow / multi-user-basic CI jobs):

PR #779 changed the existence probe in get_qdrant_client from
collection_exists() (returned bool in both modes) to get_collection()
+ except UnexpectedResponse(status_code=404). The HTTP-mode client
raises UnexpectedResponse with a 404 body, but the local/in-memory
client raises ValueError(f"Collection {name} not found") — see
qdrant_client/local/async_qdrant_local.py. The narrow except clause
let the ValueError propagate, app.py's lifespan re-raised as
RuntimeError, and the mcp container crashed on first start. Catch
ValueError too, with a `not found` substring guard so genuine
programming bugs (bad collection_name, etc.) still surface.

Tests: extend the existing 400-path test to assert the new
failed_fields contract; add two get_qdrant_client unit tests pinning
the local-mode VE catch (positive case + propagation case).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Chris Coutinho
2026-05-10 18:33:51 +02:00
co-authored by Claude Opus 4.7
parent 363c2a2624
commit 8246d9a088
3 changed files with 184 additions and 14 deletions
+24 -1
View File
@@ -111,7 +111,15 @@ async def _create_one_payload_index(
logger.warning(
"Schema conflict on payload index '%s': %s", field, body_text
)
return True
# Treat schema conflict the same as a wrong-type index
# discovered via `existing_schema` in `_ensure_payload_indexes`
# (lines 195-206) — both are "the index present is not the
# one we'd build", so the consolidated `Payload index
# creation incomplete` summary should fire in both cases.
# Without this, tenants whose payload_schema is hidden from
# their JWT (Qdrant Cloud collection-scoped tokens) would
# only see the per-field WARNING and miss the summary.
return False
logger.error(
"Unexpected error creating payload index on '%s' (status %s): %s",
field,
@@ -580,6 +588,21 @@ async def get_qdrant_client() -> AsyncQdrantClient:
if exc.status_code != 404:
raise
logger.debug(f"Collection '{collection_name}' not found (404).")
except ValueError as exc:
# Local/in-memory qdrant_client raises ValueError(f"Collection
# {name} not found") instead of UnexpectedResponse — see
# qdrant_client/local/async_qdrant_local.py. Match on the
# message rather than catching every ValueError so genuine
# programming bugs (bad collection_name validation, etc.)
# still propagate. PR #779 introduced this regression by
# switching the existence probe from `collection_exists()`
# (which returned a bool in both modes) to `get_collection`
# without accounting for the local-mode signalling
# convention; the failing single-user / login-flow /
# multi-user-basic CI jobs all exercise this path.
if "not found" not in str(exc):
raise
logger.debug(f"Collection '{collection_name}' not found (local mode).")
if collection_info is not None:
# Collection exists - validate dimensions