apache/beam · error · IllegalArgumentException
Unsupported field type: " + fieldType
Error message
Unsupported field type: " + fieldType
What it means
convertFromBsonValue's switch over FieldType TypeName has no case for the given field type (e.g. LOGICAL_TYPE, DATETIME, BYTES variants not handled by this helper), so it falls into default and throws. It means the MongoDbIO schema converter does not support converting that FieldType from a BSON value.
Solutions
- Change the field to a supported primitive type (STRING, INT64, DOUBLE, BOOLEAN, BYTES as handled) and convert in user code.
- Wrap values as STRING (e.g. timestamps as ISO strings) if the connector's converter lacks a case for the logical type.
- Upgrade Apache Beam — newer versions may have added support for the FieldType in MongoDbUtils.
- Implement a custom schema mapping (DoFn) instead of relying on the connector's automatic conversion.
Example fix
// before
Field.of("createdAt", FieldType.logicalType(new MyInstantLogicalType()))
// after: store as string, parse later
Field.of("createdAt", FieldType.STRING) Defensive patterns
Strategy: validation
Validate before calling
Set<TypeName> supported = Set.of(TypeName.STRING, TypeName.INT64, TypeName.INT32, TypeName.DOUBLE, TypeName.FLOAT, TypeName.BOOLEAN, TypeName.BYTES, TypeName.ARRAY, TypeName.ITERABLE, TypeName.MAP, TypeName.ROW);
schema.getFields().forEach(f -> {
if (!supported.contains(f.getType().getTypeName())) {
throw new IllegalStateException("Unsupported field type in MongoDbIO schema: " + f.getType());
}
}); Try / catch
try {
Row row = toRow(doc, schema);
} catch (IllegalArgumentException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Unsupported field type")) {
throw new SchemaConfigurationException("Use only types supported by MongoDbUtils: " + e.getMessage());
}
throw e;
} Prevention
- Restrict schemas to primitive types plus ARRAY/MAP/ROW for MongoDB sources.
- Convert logical types (timestamps, decimals) to STRING/INT64 before ingestion.
- Check the connector's supported types for your Beam version before designing the schema.
When it happens
Trigger: A schema field uses a FieldType whose TypeName is not among the handled primitives/collection/MAP/ROW cases — e.g. custom logical types, portable bytes, or unsupported logical types like instant/decimal depending on version — while reading documents via toRow.
Common situations: Custom logical types added by user code; schema inferred from Java types that map to unhandled Beam logical types; Beam version differences where new FieldTypes (e.g. new logical types) postdate the connector's converter.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Cannot convert value of type " + (value != null ?…
- Collection element type cannot be null for type: " +…
- Expected Map for type " + fieldType + ", but got: " +…
- Map value type cannot be null for type: " + fieldType
- Row schema cannot be null for type: " + fieldType
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/c498124f95a48184.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/io/mongodb/src/main/java/org/apache/beam/sdk/io/mongodb/MongoDbUtils.java:202
rowMap.put(
String.valueOf(entry.getKey()), convertFromBsonValue(entry.getValue(), valueType));
}
return rowMap;
case ROW:
Schema rowSchema = fieldType.getRowSchema();
if (rowSchema == null) {
throw new IllegalArgumentException("Row schema cannot be null for type: " + fieldType);
}
if (value instanceof Map) {
return toRow((Map<?, ?>) value, rowSchema);
} else {
throw new IllegalArgumentException(
"Cannot convert value of type "
+ (value != null ? value.getClass().getName() : "null")
+ " to Row");
}
default:
throw new IllegalArgumentException("Unsupported field type: " + fieldType);
}
}
}
View on GitHub (pinned to 12126d8942)