apache/beam · error · RuntimeException
FieldType unexpected +fieldType.getTypeName()
Error message
FieldType unexpected +fieldType.getTypeName()
What it means
primitiveRowFieldToProto maps a Java value of an atomic FieldType into a proto AtomicTypeValue. Its switch only handles the primitive cases (BYTE, INT16, INT32, INT64, FLOAT, DOUBLE, STRING, BOOLEAN, BYTES...); any other FieldType.getTypeName() reaching it hits the default branch and throws this RuntimeException. It signals internal dispatch failure: a non-primitive type was routed to the primitive encoder.
Source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/SchemaTranslation.java:813
return AtomicTypeValue.newBuilder().setByte((byte) value).build();
case INT16:
return AtomicTypeValue.newBuilder().setInt16((short) value).build();
case INT32:
return AtomicTypeValue.newBuilder().setInt32((int) value).build();
case INT64:
return AtomicTypeValue.newBuilder().setInt64((long) value).build();
case FLOAT:
return AtomicTypeValue.newBuilder().setFloat((float) value).build();
case DOUBLE:
return AtomicTypeValue.newBuilder().setDouble((double) value).build();
case STRING:
return AtomicTypeValue.newBuilder().setString((String) value).build();
case BOOLEAN:
return AtomicTypeValue.newBuilder().setBoolean((boolean) value).build();
case BYTES:
return AtomicTypeValue.newBuilder().setBytes(ByteString.copyFrom((byte[]) value)).build();
default:
throw new RuntimeException("FieldType unexpected " + fieldType.getTypeName());
}
}
private static Object primitiveFromProto(FieldType fieldType, AtomicTypeValue value) {
switch (fieldType.getTypeName()) {
case BYTE:
return (byte) value.getByte();
case INT16:
return (short) value.getInt16();
case INT32:
return value.getInt32();
case INT64:
return value.getInt64();
case FLOAT:
return value.getFloat();
case DOUBLE:
return value.getDouble();
case STRING:View on GitHub (pinned to 12126d8942)
Solutions
- Check the FieldType type name in the message; confirm your Beam version's supported primitive set.
- Upgrade beam-sdks-java-core if the type is supported in newer versions.
- Pre-convert unsupported types (e.g. DECIMAL → STRING/BYTES) before schema translation.
- File/inspect a Beam issue if a legitimate primitive type reaches the default branch — likely a dispatch bug.
Example fix
// before fieldValueToProto(FieldType.DATETIME, value); // not a handled primitive // after fieldValueToProto(FieldType.STRING, DateTimeFormat format(value)); // or upgrade Beam
Defensive patterns
Strategy: validation
Validate before calling
if (!fieldType.getTypeName().isPrimitiveType()) throw new IllegalArgumentException(fieldType + " is not primitive; primitiveRowFieldToProto cannot encode it");
Type guard
boolean isEncodablePrimitive(FieldType t) { switch (t.getTypeName()) { case BYTE: case INT16: case INT32: case INT64: case FLOAT: case DOUBLE: case STRING: case BOOLEAN: case BYTES: return true; default: return false; } } Try / catch
try { rowToProto(row); } catch (RuntimeException e) { if (e.getMessage() != null && e.getMessage().startsWith("FieldType unexpected")) { /* map type to supported primitive or upgrade Beam */ } else { throw e; } } Prevention
- Only route primitive FieldTypes to primitive encoders
- Upgrade Beam when using newly added type names
- Convert DATETIME/DECIMAL etc. to supported primitives for cross-version safety
- Cover serialization in unit tests for every schema type you use
When it happens
Trigger: fieldValueToProto dispatches to primitiveRowFieldToProto with a FieldType whose TypeName is not a primitive — typically due to a missing case in the caller's switch or a schema type added in a newer Beam than the running one.
Common situations: Version skew with newly added type names; custom code calling fieldValueToProto with a DATETIME/DECIMAL type not covered in that Beam version; internal dispatch bug after schema evolution.
Related errors
- The input schema must have exactly one field of type byte.
- Could not encode message as bytes
- Null value found for field that doesn't support nulls.
- Cannot merge two types: +fieldType1.getTypeName()+ and +fiel
- value type is '%s' for field type '%s'
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/3c3105c8830a89a5.
Report an issue: GitHub.