apache/beam · error · ValueError
Unable to convert to a Beam schema.
Error message
Unable to convert {json_type} to a Beam schema. What it means
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.
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
Example fix
// before
{"properties": {"price": {"type": "float"}}}
// after
{"properties": {"price": {"type": "number"}}} Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED = {'string','integer','number','boolean','array','object'} # plus keys in JSON_ATOMIC_TYPES_TO_BEAM
def assert_supported_types(json_schema):
for name, t in json_schema.get('properties', {}).items():
tn = t.get('type')
if tn and tn not in SUPPORTED and tn not in ('array','object'):
raise ValueError(f'Unsupported JSON type {tn!r} for field {name}') Type guard
def is_supported_type(t) -> bool:
return isinstance(t, dict) and t.get('type') in {'string','integer','number','boolean','array','object'} Try / catch
try:
beam_type = json_type_to_beam_type(t)
except ValueError as e:
raise ValueError(f'Field type not convertible to Beam schema: {e}') from e Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Malformed type .
- Expected an instance of ShardedKeyTypeConstraint, but got a
- Expected object type, got
- Incompatible schema for
- Incompatible types: map vs object
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/05ec406f133074ea.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/yaml/json_utils.py:111
array_type=schema_pb2.ArrayType(
element_type=json_type_to_beam_type(json_type['items'])))
elif type_name == 'object':
if 'properties' in json_type:
return schema_pb2.FieldType(
row_type=schema_pb2.RowType(
schema=json_schema_to_beam_schema(json_type)))
elif 'additionalProperties' in json_type:
return schema_pb2.FieldType(
map_type=schema_pb2.MapType(
key_type=schema_pb2.FieldType(atomic_type=schema_pb2.STRING),
value_type=json_type_to_beam_type(
json_type['additionalProperties'])))
else:
raise ValueError(
f'Object type must have either properties or additionalProperties, '
f'got {json_type}.')
else:
raise ValueError(f'Unable to convert {json_type} to a Beam schema.')
def beam_schema_to_json_schema(
beam_schema: schema_pb2.Schema) -> dict[str, Any]:
return {
'type': 'object',
'properties': {
field.name: beam_type_to_json_type(field.type)
for field in beam_schema.fields
},
'additionalProperties': False
}
def beam_type_to_json_type(beam_type: schema_pb2.FieldType) -> dict[str, Any]:
type_info = beam_type.WhichOneof("type_info")
if type_info == "atomic_type":
if beam_type.atomic_type in BEAM_ATOMIC_TYPES_TO_JSON:View on GitHub (pinned to 12126d8942)