{"record":{"id":"d636f8a54b7b16ab","repo":"cocoindex-io/cocoindex","slug":"unexpected-schema-type-type-resolved-schema","errorCode":null,"errorMessage":"Unexpected schema type: {type(resolved_schema)}","messagePattern":"Unexpected schema type: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/cocoindex/connectors/qdrant/_target.py","lineNumber":704,"sourceCode":"\n\ndef _vector_params_from_def(\n    vector_def: _ResolvedQdrantVectorDef,\n) -> qdrant_models.VectorParams:\n    \"\"\"Convert a resolved vector definition to Qdrant VectorParams.\"\"\"\n    resolved_schema = vector_def.schema\n    multivector_config = None\n\n    if isinstance(resolved_schema, res_schema.VectorSchema):\n        dim = resolved_schema.size\n    elif isinstance(resolved_schema, res_schema.MultiVectorSchema):\n        dim = resolved_schema.vector_schema.size\n        # For multivector, use the specified comparator\n        multivector_config = qdrant_models.MultiVectorConfig(\n            comparator=_multivector_comparator(vector_def.multivector_comparator)\n        )\n    else:\n        raise ValueError(f\"Unexpected schema type: {type(resolved_schema)}\")\n\n    return qdrant_models.VectorParams(\n        size=dim,\n        distance=_distance_from_spec(vector_def.distance),\n        multivector_config=multivector_config,\n    )\n\n\ndef _sparse_vector_params_from_def(\n    sparse_vector_def: _ResolvedQdrantSparseVectorDef,\n) -> qdrant_models.SparseVectorParams:\n    \"\"\"Convert a resolved sparse vector definition to Qdrant SparseVectorParams.\"\"\"\n    return qdrant_models.SparseVectorParams(\n        modifier=_sparse_modifier_from_spec(sparse_vector_def.modifier)\n    )\n\n\ndef _validate_vector_names(names: Collection[str], kind: str) -> None:","sourceCodeStart":686,"sourceCodeEnd":722,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/connectors/qdrant/_target.py#L686-L722","documentation":"_vector_params_from_def expects the resolved schema attached to the vector def to be a recognized schema type (dense or multivector VectorSchema). If the resolved schema is of an unexpected type, this internal-invariant ValueError is raised while building qdrant_models.VectorParams during collection creation.","triggerScenarios":"Reaching collection creation with a QdrantVectorDef whose resolved vector_schema is neither the expected dense nor multivector schema type — typically after constructing/patching a QdrantVectorDef manually or constructing CollectionSchema via the sync __init__ with a hand-built resolved def rather than through the async create() resolver.","commonSituations":"Subclassing or monkey-patching the schema types; bypassing CollectionSchema.create() and passing arbitrary objects as _vectors; version mismatch between cocoindex and code that builds internal resolved types directly.","solutions":["Construct schemas only through the public API (QdrantVectorDef with a VectorSchema, resolved via await CollectionSchema.create(...)) instead of instantiating internal resolved types.","Check that the VectorSchema passed to QdrantVectorDef is a genuine cocoindex.resources.schema.VectorSchema (or multivector variant), not a look-alike object.","Upgrade cocoindex if you rely on internals whose shape changed between versions."],"exampleFix":"// before\nschema = CollectionSchema(QdrantVectorDef(schema=custom_obj, distance=\"cosine\"))  # internal ctor\n// after\nschema = await CollectionSchema.create(vectors=QdrantVectorDef(schema=VectorSchema(dtype=np.float32, size=384), distance=\"cosine\"))","handlingStrategy":"type-guard","validationCode":"from cocoindex.resources.schema import VectorSchema\nassert isinstance(vector_def.schema, VectorSchema), type(vector_def.schema)","typeGuard":"isinstance(resolved_schema, (VectorSchema, MultivectorVectorSchema))  # use the public schema classes, not internal resolved types","tryCatchPattern":"try:\n    schema = await CollectionSchema.create(vectors=def_)\nexcept ValueError as e:\n    raise InternalError(f\"vector schema unexpected type: {e}\") from None","preventionTips":["Only construct CollectionSchema through the async create() classmethod.","Pass real cocoindex VectorSchema objects, not ad-hoc dataclasses.","Avoid importing/patching internal _Resolved* types."],"tags":["qdrant","internal","schema"],"backgroundTag":"internal-invariant-violation","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"}