{"record":{"id":"75644ec4921ccb36","repo":"cocoindex-io/cocoindex","slug":"vectorschemaprovider-is-only-supported-for-numpy-n-75644e","errorCode":null,"errorMessage":"VectorSchemaProvider is only supported for NumPy ndarray type. Got type: {python_type}","messagePattern":"VectorSchemaProvider is only supported for NumPy ndarray type\\. Got type: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/cocoindex/connectors/neo4j/_target.py","lineNumber":321,"sourceCode":"        if isinstance(annotation, Neo4jType):\n            return _TypeMapping(annotation.neo4j_type, annotation.encoder)\n\n    base_type = type_info.base_type\n\n    if base_type in _LEAF_TYPE_MAPPINGS:\n        return _LEAF_TYPE_MAPPINGS[base_type]\n\n    if base_type is np.ndarray:\n        if vector_schema is None:\n            raise ValueError(\"VectorSchemaProvider is required for NumPy ndarray type.\")\n        if vector_schema.size <= 0:\n            raise ValueError(f\"Invalid vector dimension: {vector_schema.size}\")\n        return _TypeMapping(\n            neo4j_type=\"LIST<FLOAT>\",\n            encoder=_ndarray_to_list,\n        )\n    elif vector_schema is not None:\n        raise ValueError(\n            \"VectorSchemaProvider is only supported for NumPy ndarray type. \"\n            f\"Got type: {python_type}\"\n        )\n\n    if isinstance(type_info.variant, (SequenceType,)):\n        return _ARRAY_MAPPING\n    if isinstance(type_info.variant, (MappingType, RecordType, UnionType, AnyType)):\n        return _OBJECT_MAPPING\n\n    return _OBJECT_MAPPING\n\n\n# ---------------------------------------------------------------------------\n# ColumnDef\n# ---------------------------------------------------------------------------\n\n\nclass ColumnDef(NamedTuple):","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/connectors/neo4j/_target.py#L303-L339","documentation":"This ValueError is raised by _get_type_mapping when a VectorSchemaProvider is provided for a column whose Python type is not numpy.ndarray. Vector schema overrides only make sense for ndarray (vector) columns; applying one to any other type is a configuration contradiction, so the connector rejects it and names the offending type.","triggerScenarios":"Passing column_overrides={\"<col>\": VectorSchemaProvider(...)} for a column typed str, int, list[float], or any non-ndarray type in the record type.","commonSituations":"Refactoring a column from np.ndarray to list[float] while leaving the override in place; copy-pasting override dicts between schemas; a generic column_overrides map applied to multiple record types.","solutions":["Remove the VectorSchemaProvider override for non-ndarray columns.","Change the column's type to np.ndarray if it is genuinely a vector.","Split the overrides dict per record type so overrides match each schema's fields."],"exampleFix":"// before\ncolumn_overrides={\"embedding\": VectorSchemaProvider(size=384)}  # embedding: list[float]\n// after\n# either change the field to np.ndarray, or drop the override:\ncolumn_overrides={}","handlingStrategy":"type-guard","validationCode":"import dataclasses, numpy as np\nfrom cocoindex.resources import schema as res_schema\nvector_cols = {f.name for f in dataclasses.fields(Record) if f.type is np.ndarray}\noverrides = {k: v for k, v in overrides.items()\n             if not isinstance(v, res_schema.VectorSchemaProvider) or k in vector_cols}","typeGuard":"def is_vector_column(record_type, name: str) -> bool:\n    import dataclasses, numpy as np\n    return any(f.name == name and f.type is np.ndarray\n               for f in dataclasses.fields(record_type))","tryCatchPattern":"try:\n    schema = await TableSchema.from_class(Record, column_overrides=overrides)\nexcept ValueError as e:\n    raise RuntimeError(f\"column_overrides do not match record fields: {e}\") from e","preventionTips":["Keep one overrides dict per record type; never share it across schemas","Filter overrides against the record's actual field types before passing","When changing a column's type, update or remove its override in the same change"],"tags":["neo4j","vector","type-mismatch","schema"],"backgroundTag":"type-mismatch","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"}