{"record":{"id":"7a744bd1678c079d","repo":"pathwaycom/pathway","slug":"column-k-r-contains-a-value-of-unsupported-type","errorCode":null,"errorMessage":"Column {k!r} contains a value of unsupported type {type(v).__name__!r}. pw.io.milvus.write supports the following Pathway types: int, float, str, bool, pw.Json, list[float], bytes, and numpy.ndarray (1-D only).","messagePattern":"Column (.+?) contains a value of unsupported type (.+?)\\. pw\\.io\\.milvus\\.write supports the following Pathway types: int, float, str, bool, pw\\.Json, list\\[float\\], bytes, and numpy\\.ndarray \\(1-D only\\)\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/pathway/io/milvus/__init__.py","lineNumber":48,"sourceCode":"    to lists, and validates that every value belongs to a type the Milvus\n    connector supports.  Raises ``TypeError`` with a descriptive message for\n    unsupported types, and ``ValueError`` for multi-dimensional arrays or for a\n    vector containing a non-finite (NaN / infinity) component.\n    \"\"\"\n    result = {}\n    for k, v in row.items():\n        if isinstance(v, _PwJson):\n            v = v.value\n        if isinstance(v, np.ndarray):\n            if v.ndim != 1:\n                raise ValueError(\n                    f\"Column {k!r} contains a {v.ndim}-dimensional numpy array. \"\n                    f\"pw.io.milvus.write only supports 1-D arrays (for \"\n                    f\"FLOAT_VECTOR / BINARY_VECTOR fields).\"\n                )\n            v = v.tolist()\n        elif not isinstance(v, _SUPPORTED_TYPES):\n            raise TypeError(\n                f\"Column {k!r} contains a value of unsupported type \"\n                f\"{type(v).__name__!r}. pw.io.milvus.write supports the \"\n                f\"following Pathway types: int, float, str, bool, pw.Json, \"\n                f\"list[float], bytes, and numpy.ndarray (1-D only).\"\n            )\n        # A FLOAT_VECTOR (list / tuple / 1-D array of floats) with a non-finite\n        # component is silently stored by Milvus and corrupts the index —\n        # distances against NaN/infinity are meaningless. Reject it up front with\n        # a clear, column-named error, as the other vector sinks do.\n        if isinstance(v, (list, tuple)) and any(\n            isinstance(x, float) and not math.isfinite(x) for x in v\n        ):\n            raise ValueError(\n                f\"Column {k!r} contains a non-finite value (NaN or infinity) in \"\n                f\"its vector, which cannot be indexed by Milvus.\"\n            )\n        result[k] = v\n    return result","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/io/milvus/__init__.py#L30-L66","documentation":"pw.io.milvus.write can only serialize a fixed set of Python/Pathway types: int, float, str, bool, pw.Json, list[float], bytes, and 1-D numpy arrays. Any other Python object in a row triggers this TypeError, naming the column and the unsupported type's name so the offending field is easy to locate.","triggerScenarios":"Rows containing values such as datetime.datetime, None, dict (unwrapped from Json), set, np.float32 scalars, or tuples after preprocessing; commonly an apply() without dtype handling that leaks arbitrary objects.","commonSituations":"Leaking None from a UDF (use Optional/None handling in the schema); passing datetime objects instead of ISO strings; dicts not wrapped in pw.Json; numpy scalar types instead of Python scalars.","solutions":["Convert the offending column before writing: datetimes via .strftime('%Y-%m-%dT%H:%M:%S'), dicts via pw.Json(...), numpy scalars via .item()","Handle None with the column dtype's Optional type or replace with defaults so rows never carry raw None into the sink","Inspect one materialized row (pw.debug.compute_and_print) to find which column holds the unsupported type"],"exampleFix":"# before\nt = t.with_columns(created=t.created_at)  # datetime objects\n\n# after\nt = t.with_columns(created=t.created_at.dt.strftime('%Y-%m-%dT%H:%M:%S'))","handlingStrategy":"type-guard","validationCode":"SUPPORTED = (int, float, str, bool, bytes, list, tuple)\ndef row_ok(row: dict) -> bool:\n    return all(v is None is False and isinstance(v, SUPPORTED) or type(v).__name__ == \"Json\" for v in row.values())","typeGuard":"def is_milvus_supported(v) -> bool:\n    return isinstance(v, (int, float, str, bool, bytes, np.ndarray)) or type(v).__name__ in (\"Json\", \"list\", \"tuple\")","tryCatchPattern":"try:\n    pw.io.milvus.write(table, uri, \"docs\", primary_key=table.id)\nexcept TypeError as e:\n    if \"unsupported type\" in str(e):\n        bad_col = str(e).split(\"'\")[1]  # column named in message\n        raise ValueError(f\"Convert column {bad_col} (e.g. datetime -> ISO str) before writing\") from e\n    raise","preventionTips":["Normalize rows before the sink: datetimes to ISO strings, dicts to pw.Json, numpy scalars to .item()","Avoid None in non-optional columns by fixing the schema dtype","Print one row with pw.debug.compute_and_print to spot exotic types early"],"tags":["milvus","pathway","type-mismatch","serialization","validation"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}