{"record":{"id":"82e4e7cc4113165d","repo":"cocoindex-io/cocoindex","slug":"vectorschemaprovider-is-only-supported-for-numpy-n-82e4e7","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/surrealdb/_target.py","lineNumber":294,"sourceCode":"\n    # Check direct leaf type mappings\n    if base_type in _LEAF_TYPE_MAPPINGS:\n        return _LEAF_TYPE_MAPPINGS[base_type]\n\n    # NumPy ndarray: map to array<float, 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\n        return _TypeMapping(\n            surreal_type=f\"array<float, {vector_schema.size}>\",\n            encoder=_ndarray_encoder,\n        )\n\n    elif vector_schema is not None:\n        raise ValueError(\n            f\"VectorSchemaProvider is only supported for NumPy ndarray type. \"\n            f\"Got type: {python_type}\"\n        )\n\n    # Complex types that need JSON encoding\n    if isinstance(\n        type_info.variant, (SequenceType, MappingType, RecordType, UnionType, AnyType)\n    ):\n        return _OBJECT_MAPPING\n\n    # Default fallback\n    return _OBJECT_MAPPING\n\n\n# ---------------------------------------------------------------------------\n# ColumnDef\n# ---------------------------------------------------------------------------\n","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/connectors/surrealdb/_target.py#L276-L312","documentation":"A VectorSchemaProvider was supplied for a field whose Python type is not numpy.ndarray. Vector schemas are only meaningful for ndarray fields (mapped to array<float, N>), so CocoIndex rejects the combination, including the offending Python type in the message.","triggerScenarios":"Declaring a SurrealDB column with vector_schema set for a field typed as list[float], list, or any non-ndarray type in the record type used by table_target/relation_target.","commonSituations":"Switching a field from np.ndarray to a plain list[float] (or a memoryview/bytes embedding) without removing the vector schema; copy-pasting column definitions between tables where one used ndarray.","solutions":["Remove the vector_schema from the non-ndarray field's column definition.","Or change the field type back to np.ndarray if vector semantics with a fixed dimension are intended.","If using lists, encode as a regular array/JSON column instead of a vector column."],"exampleFix":"// before\n{\"embedding\": (list[float], VectorSchemaProvider(size=768))}\n// after\n{\"embedding\": np.ndarray, \"vector_schema\": VectorSchemaProvider(size=768)}","handlingStrategy":"type-guard","validationCode":"import numpy as np\nif python_type is not np.ndarray and vector_schema is not None:\n    raise ValueError(\"vector_schema only allowed for np.ndarray fields\")","typeGuard":"def vector_schema_type_valid(python_type, vector_schema) -> bool:\n    import numpy as np\n    return vector_schema is None or python_type is np.ndarray","tryCatchPattern":"try:\n    target = table_target(record_type, ...)\nexcept ValueError as e:\n    if \"only supported for NumPy ndarray\" in str(e):\n        # drop vector_schema or switch the field to np.ndarray\n        ...","preventionTips":["Only set vector_schema on fields annotated np.ndarray.","When changing a field type, audit attached column options like vector_schema.","Keep column option and field type definitions adjacent so mismatches are visible in review."],"tags":["surrealdb","vector","type-mismatch","schema"],"backgroundTag":"incompatible-source-type","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"}