{"record":{"id":"05ec406f133074ea","repo":"apache/beam","slug":"unable-to-convert-json-type-to-a-beam-schema","errorCode":null,"errorMessage":"Unable to convert {json_type} to a Beam schema.","messagePattern":"Unable to convert (.+?) to a Beam schema\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/yaml/json_utils.py","lineNumber":111,"sourceCode":"        array_type=schema_pb2.ArrayType(\n            element_type=json_type_to_beam_type(json_type['items'])))\n  elif type_name == 'object':\n    if 'properties' in json_type:\n      return schema_pb2.FieldType(\n          row_type=schema_pb2.RowType(\n              schema=json_schema_to_beam_schema(json_type)))\n    elif 'additionalProperties' in json_type:\n      return schema_pb2.FieldType(\n          map_type=schema_pb2.MapType(\n              key_type=schema_pb2.FieldType(atomic_type=schema_pb2.STRING),\n              value_type=json_type_to_beam_type(\n                  json_type['additionalProperties'])))\n    else:\n      raise ValueError(\n          f'Object type must have either properties or additionalProperties, '\n          f'got {json_type}.')\n  else:\n    raise ValueError(f'Unable to convert {json_type} to a Beam schema.')\n\n\ndef beam_schema_to_json_schema(\n    beam_schema: schema_pb2.Schema) -> dict[str, Any]:\n  return {\n      'type': 'object',\n      'properties': {\n          field.name: beam_type_to_json_type(field.type)\n          for field in beam_schema.fields\n      },\n      'additionalProperties': False\n  }\n\n\ndef beam_type_to_json_type(beam_type: schema_pb2.FieldType) -> dict[str, Any]:\n  type_info = beam_type.WhichOneof(\"type_info\")\n  if type_info == \"atomic_type\":\n    if beam_type.atomic_type in BEAM_ATOMIC_TYPES_TO_JSON:","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/yaml/json_utils.py#L93-L129","documentation":"json_type_to_beam_type's final else branch raises when the JSON schema's 'type' name is not one it knows (atomic types, object, or array). The type name may be misspelled, unsupported (e.g. 'integer' vs 'int', 'number', 'boolean' depending on JSON_ATOMIC_TYPES_TO_BEAM), or the schema may not be a JSON Schema type definition at all.","triggerScenarios":"Passing a schema dict whose json_type['type'] is an unsupported/misspelled name (e.g. {\"type\": \"float\"} or {\"type\": \"datetime\"}) into json_type_to_beam_type via json_schema_to_beam_type.","commonSituations":"Using SQL/Avro type names (float, long, timestamp) instead of JSON Schema names (number, integer, string); custom logical types; older Beam versions lacking a mapping for a valid JSON Schema type name.","solutions":["Use standard JSON Schema type names: string, integer, number, boolean, array, object","Check JSON_ATOMIC_TYPES_TO_BEAM in json_utils.py for the exact supported set in your Beam version","Pre-process unsupported types (e.g. convert timestamps to string with a format annotation)","Upgrade apache-beam if a newer version maps the type you need"],"exampleFix":"// before\n{\"properties\": {\"price\": {\"type\": \"float\"}}}\n// after\n{\"properties\": {\"price\": {\"type\": \"number\"}}}","handlingStrategy":"validation","validationCode":"SUPPORTED = {'string','integer','number','boolean','array','object'}  # plus keys in JSON_ATOMIC_TYPES_TO_BEAM\ndef assert_supported_types(json_schema):\n    for name, t in json_schema.get('properties', {}).items():\n        tn = t.get('type')\n        if tn and tn not in SUPPORTED and tn not in ('array','object'):\n            raise ValueError(f'Unsupported JSON type {tn!r} for field {name}')","typeGuard":"def is_supported_type(t) -> bool:\n    return isinstance(t, dict) and t.get('type') in {'string','integer','number','boolean','array','object'}","tryCatchPattern":"try:\n    beam_type = json_type_to_beam_type(t)\nexcept ValueError as e:\n    raise ValueError(f'Field type not convertible to Beam schema: {e}') from e","preventionTips":["Use only standard JSON Schema type names","Check JSON_ATOMIC_TYPES_TO_BEAM in json_utils.py for your Beam version","Convert SQL/Avro type names (float, long, timestamp) to JSON Schema equivalents before use"],"tags":["python","apache-beam","json-schema","type-system"],"backgroundTag":"unsupported-enum-value","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"}