cocoindex-io/cocoindex · error · ValueError
Unexpected schema type: {type(resolved_schema)}
Error message
Unexpected schema type: {type(resolved_schema)} What it means
_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.
Source
Thrown at python/cocoindex/connectors/qdrant/_target.py:704
def _vector_params_from_def(
vector_def: _ResolvedQdrantVectorDef,
) -> qdrant_models.VectorParams:
"""Convert a resolved vector definition to Qdrant VectorParams."""
resolved_schema = vector_def.schema
multivector_config = None
if isinstance(resolved_schema, res_schema.VectorSchema):
dim = resolved_schema.size
elif isinstance(resolved_schema, res_schema.MultiVectorSchema):
dim = resolved_schema.vector_schema.size
# For multivector, use the specified comparator
multivector_config = qdrant_models.MultiVectorConfig(
comparator=_multivector_comparator(vector_def.multivector_comparator)
)
else:
raise ValueError(f"Unexpected schema type: {type(resolved_schema)}")
return qdrant_models.VectorParams(
size=dim,
distance=_distance_from_spec(vector_def.distance),
multivector_config=multivector_config,
)
def _sparse_vector_params_from_def(
sparse_vector_def: _ResolvedQdrantSparseVectorDef,
) -> qdrant_models.SparseVectorParams:
"""Convert a resolved sparse vector definition to Qdrant SparseVectorParams."""
return qdrant_models.SparseVectorParams(
modifier=_sparse_modifier_from_spec(sparse_vector_def.modifier)
)
def _validate_vector_names(names: Collection[str], kind: str) -> None:View on GitHub (pinned to e84aa99b32)
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.
Example fix
// before schema = CollectionSchema(QdrantVectorDef(schema=custom_obj, distance="cosine")) # internal ctor // after schema = await CollectionSchema.create(vectors=QdrantVectorDef(schema=VectorSchema(dtype=np.float32, size=384), distance="cosine"))
Defensive patterns
Strategy: type-guard
Validate before calling
from cocoindex.resources.schema import VectorSchema assert isinstance(vector_def.schema, VectorSchema), type(vector_def.schema)
Type guard
isinstance(resolved_schema, (VectorSchema, MultivectorVectorSchema)) # use the public schema classes, not internal resolved types
Try / catch
try:
schema = await CollectionSchema.create(vectors=def_)
except ValueError as e:
raise InternalError(f"vector schema unexpected type: {e}") from None Prevention
- Only construct CollectionSchema through the async create() classmethod.
- Pass real cocoindex VectorSchema objects, not ad-hoc dataclasses.
- Avoid importing/patching internal _Resolved* types.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Unexpected column subkey format: {sub_key!r}, expected to st
- Unsupported record type: {self.record_type}
- Primary key column '{pk}' not found in columns: {list(self.c
- VectorSchemaProvider is required for NumPy ndarray type.
- VectorSchemaProvider only supported for ndarray. Got: {pytho
AI-assisted analysis of cocoindex-io/cocoindex@e84aa99b32 (2026-09-08).
Data as JSON: /api/errors/d636f8a54b7b16ab.
Report an issue: GitHub.