{"record":{"id":"9a5eb67152568959","repo":"cocoindex-io/cocoindex","slug":"qdrant-named-vectors-must-not-be-empty","errorCode":null,"errorMessage":"Qdrant named vectors must not be empty","messagePattern":"Qdrant named vectors must not be empty","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/cocoindex/connectors/qdrant/_target.py","lineNumber":206,"sourceCode":"        Args:\n            vectors: Either a single QdrantVectorDef (for an unnamed dense\n                     vector) or a dictionary mapping vector names to\n                     QdrantVectorDef or QdrantSparseVectorDef. Dense and\n                     sparse vectors share one namespace in Qdrant, so both\n                     kinds live in the same dict; sparse vectors are always\n                     named.\n        \"\"\"\n        resolved: _ResolvedQdrantVectorDef | _ResolvedQdrantNamedVectorsDef\n        if isinstance(vectors, QdrantVectorDef):\n            resolved = await _resolve_vector_def(vectors)\n        elif isinstance(vectors, QdrantSparseVectorDef):\n            raise ValueError(\n                \"Qdrant sparse vectors are always named; pass them in a dict, \"\n                'e.g. vectors={\"sparse\": QdrantSparseVectorDef()}'\n            )\n        elif isinstance(vectors, dict):\n            if not vectors:\n                raise ValueError(\"Qdrant named vectors must not be empty\")\n            _validate_vector_names(vectors.keys(), \"vector\")\n            resolved_entries: dict[\n                str, _ResolvedQdrantVectorDef | _ResolvedQdrantSparseVectorDef\n            ] = {}\n            for name, vector_def in vectors.items():\n                if isinstance(vector_def, QdrantVectorDef):\n                    resolved_entries[name] = await _resolve_vector_def(vector_def)\n                elif isinstance(vector_def, QdrantSparseVectorDef):\n                    resolved_entries[name] = _resolve_sparse_vector_def(vector_def)\n                else:\n                    raise ValueError(f\"Invalid vector definition: {vector_def}\")\n            resolved = _ResolvedQdrantNamedVectorsDef(vectors=resolved_entries)\n        elif vectors is None:\n            raise ValueError(\n                \"Qdrant collection schema must declare at least one vector\"\n            )\n        else:\n            raise ValueError(f\"Invalid vector definition: {vectors}\")","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/connectors/qdrant/_target.py#L188-L224","documentation":"Raised in `create` when the `vectors` dict is empty. A Qdrant collection built from a schema must declare at least one vector; an empty named-vectors dict has nothing to create and is rejected explicitly rather than producing a broken collection.","triggerScenarios":"Calling `create(vectors={})` — often the result of building the dict programmatically from a filter that matched nothing.","commonSituations":"Generating vector defs from config where the vector list was accidentally filtered out; a bug upstream that yields an empty mapping; deleting all vectors from a collection definition without removing the collection.","solutions":["Pass at least one named vector definition, e.g. `vectors={\"dense\": QdrantVectorDef(...)}`.","If no vector is needed, don't create a vector-based collection for this schema.","Fix the upstream code that produces the empty dict (log its contents before create)."],"exampleFix":"// before\ncreate(vectors={})\n// after\ncreate(vectors={\"dense\": QdrantVectorDef(dimension=768, distance=QdrantDistance.COSINE)})","handlingStrategy":"validation","validationCode":"def require_vectors(vectors: dict) -> dict:\n    if not vectors:\n        raise ValueError(\"At least one named vector required\")\n    return vectors","typeGuard":"def has_vectors(v) -> bool:\n    return isinstance(v, dict) and len(v) > 0 or hasattr(v, 'dimension')","tryCatchPattern":"try:\n    collection = await QdrantCollection.create(..., vectors=vector_defs)\nexcept ValueError as e:\n    if \"must not be empty\" in str(e):\n        logger.error(\"vector_defs built empty: %r\", vector_defs)\n    else:\n        raise","preventionTips":["Assert the vector dict is non-empty before create.","Log vector definitions built from dynamic config.","Fail early in config parsing rather than at create time."],"tags":["qdrant","vectors","empty-collection"],"backgroundTag":"empty-required-field","analyzedSha":"e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b","analyzedAt":"2026-09-08T15:59:19.997Z","contentChangedAt":"2026-09-08T15:59:19.997Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}