{"record":{"id":"fc5339f0b17d8c33","repo":"cocoindex-io/cocoindex","slug":"invalid-vector-definition-vector-def","errorCode":null,"errorMessage":"Invalid vector definition: {vector_def}","messagePattern":"Invalid vector definition: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/cocoindex/connectors/qdrant/_target.py","lineNumber":122,"sourceCode":"    Dense and sparse vectors share one namespace in Qdrant (the server\n    rejects duplicate names across the two kinds), so a single dict holds\n    both; the tagged union discriminates them.\n    \"\"\"\n\n    vectors: dict[str, _ResolvedQdrantVectorDef | _ResolvedQdrantSparseVectorDef]\n\n\nasync def _resolve_vector_def(vector_def: QdrantVectorDef) -> _ResolvedQdrantVectorDef:\n    resolved_schema: res_schema.VectorSchema | res_schema.MultiVectorSchema\n    vs = await res_schema.get_vector_schema(vector_def.schema)\n    if vs is not None:\n        resolved_schema = vs\n    else:\n        mvs = await res_schema.get_multi_vector_schema(vector_def.schema)\n        if mvs is not None:\n            resolved_schema = mvs\n        else:\n            raise ValueError(f\"Invalid vector definition: {vector_def}\")\n    return _ResolvedQdrantVectorDef(\n        schema=resolved_schema,\n        distance=vector_def.distance,\n        multivector_comparator=vector_def.multivector_comparator,\n    )\n\n\ndef _resolve_sparse_vector_def(\n    sparse_vector_def: QdrantSparseVectorDef,\n) -> _ResolvedQdrantSparseVectorDef:\n    return _ResolvedQdrantSparseVectorDef(modifier=sparse_vector_def.modifier)\n\n\n@dataclass(slots=True)\nclass CollectionSchema:\n    \"\"\"Schema definition for a Qdrant collection.\n\n    Defines the vector fields for the collection. Each vector field is specified by name","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/connectors/qdrant/_target.py#L104-L140","documentation":"Raised by `_resolve_vector_def` when a QdrantVectorDef references a vector schema name that cannot be resolved: the resource schema's default vector schema is absent and no multi-vector schema exists under the given name. The definition is therefore invalid and the collection cannot be created.","triggerScenarios":"Creating a Qdrant collection with `QdrantVectorDef(schema='some_name', ...)` where `get_vector_schema` returns None and `get_multi_vector_schema('some_name')` also returns None — i.e. the named vector schema was never declared.","commonSituations":"Typo in the schema name; declaring vectors before registering their vector schema in the resource schema; renaming a vector schema and missing one call site.","solutions":["Declare/register the vector schema under the exact name referenced by QdrantVectorDef(schema=...).","Fix the schema name typo to match the registered vector schema.","If a default (unnamed) vector was intended, construct QdrantVectorDef without a schema name and ensure a default vector schema exists.","Verify resolution order: get_vector_schema for default, get_multi_vector_schema for named/multi vectors."],"exampleFix":"// before\nQdrantVectorDef(schema=\"embdeding\", distance=Cosine)  # undeclared name\n// after\nQdrantVectorDef(schema=\"embedding\", distance=Cosine)  # matches declared schema","handlingStrategy":"validation","validationCode":"# before create:\n# declared = set(res_schema vector schema names)\n# if vector_def.schema not in declared: raise ValueError(vector_def.schema)","typeGuard":"def schema_is_declared(res_schema, name: str | None) -> bool:\n    if name is None:\n        return res_schema.get_vector_schema() is not None\n    return res_schema.get_multi_vector_schema(name) is not None","tryCatchPattern":"try:\n    collection = await QdrantCollection.create(..., vectors=vector_def)\nexcept ValueError as e:\n    if \"Invalid vector definition\" in str(e):\n        logger.error(\"Vector schema %r not declared\", vector_def.schema)\n    else:\n        raise","preventionTips":["Declare vector schemas before referencing them in QdrantVectorDef.","Use shared constants for schema names.","Rename vector schemas via project-wide search/replace."],"tags":["qdrant","vector-schema","configuration"],"backgroundTag":"invalid-config-value","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"}