{"record":{"id":"daa8b70b2f65da69","repo":"apache/beam","slug":"unconvertable-type-beam-type","errorCode":null,"errorMessage":"Unconvertable type: {beam_type}","messagePattern":"Unconvertable type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/io/avroio.py","lineNumber":748,"sourceCode":"  elif type_info == \"map_type\":\n    if beam_type.map_type.key_type.atomic_type != schema_pb2.STRING:\n      raise TypeError(\n          f'Only strings allowed as map keys when converting to AVRO, '\n          f'found {beam_type}')\n    return {\n        'type': 'map',\n        'values': unnest_primitive_type(beam_type.map_type.element_type)\n    }\n  elif type_info == \"row_type\":\n    return {\n        'type': 'record',\n        'name': beam_type.row_type.schema.id,\n        'fields': [{\n            'name': field.name, 'type': unnest_primitive_type(field.type)\n        } for field in beam_type.row_type.schema.fields],\n    }\n  else:\n    raise ValueError(f\"Unconvertable type: {beam_type}\")\n\n\ndef beam_row_to_avro_dict(\n    avro_schema: _AvroSchemaType, beam_schema: schema_pb2.Schema):\n  if isinstance(avro_schema, str):\n    return beam_row_to_avro_dict({'type': avro_schema}, beam_schema)\n  if avro_schema['type'] == 'record':\n    return beam_value_to_avro_value(\n        schema_pb2.FieldType(row_type=schema_pb2.RowType(schema=beam_schema)))\n  else:\n    convert = beam_value_to_avro_value(beam_schema)\n    return lambda row: convert(row[0])\n\n\ndef beam_value_to_avro_value(\n    beam_type: schema_pb2.FieldType) -> Callable[[Any], Any]:\n  type_info = beam_type.WhichOneof(\"type_info\")\n  if type_info == \"atomic_type\":","sourceCodeStart":730,"sourceCodeEnd":766,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/io/avroio.py#L730-L766","documentation":"beam_type_to_avro_type raises this ValueError when the given Beam SchemaJava type matches none of the handled AVRO-mappable categories (primitive, iterable, map, row). It is the fall-through guard of the Beam-to-AVRO schema converter, meaning the type system crossing cannot represent this Beam type in AVRO.","triggerScenarios":"Calling beam_schema_to_avro_type()/beam_schema_to_avro_schema() with a Beam FieldType whose type_info is not one of atomic/iterable/map/row — e.g. logical/EXTENSION types or DATETIME variants outside the handled set reaching the converter.","commonSituations":"Schemas built from custom LogicalType extensions, or schemas produced by newer Beam versions with type kinds the AVRO converter doesn't cover; piping unusual Beam rows into WriteToAvro with schema= provided.","solutions":["Inspect the offending schema field and replace the unsupported type with an AVRO-mappable one (primitive, array, map with string keys, or row).","For logical types, either drop the logical wrapper (use the base representation) or extend the conversion yourself before writing.","Flatten unsupported nested structures into rows/arrays that the converter supports.","Wrap conversion in try/except ValueError to produce a schema-specific error message identifying the field."],"exampleFix":"// before\nrow = beam.Row(ts=custom_extension_type)\nWriteToAvro('out.avro', schema=beam.schema_from(row))\n// after\nrow = beam.Row(ts=str(custom_extension_type))  # use a supported primitive","handlingStrategy":"try-catch","validationCode":"def is_avro_mappable(field_type) -> bool:\n    return field_type.type_info in {\n        'atomic_type', 'iterable_type', 'map_type', 'row_type'}","typeGuard":null,"tryCatchPattern":"try:\n    avro_schema = beam_schema_to_avro_schema(beam_schema)\nexcept ValueError as e:\n    if str(e).startswith('Unconvertable type'):\n        logging.error('Unsupported Beam type for AVRO: %s', e)\n        ...\n    raise","preventionTips":["Avoid extension/logical types in schemas bound for AVRO sinks","Pin one apache-beam version across the pipeline","Test schema-to-AVRO conversion in unit tests for every record type"],"tags":["avro","beam-schema","type-mismatch","python"],"backgroundTag":"schema-validation-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}