apache/beam · error · RuntimeException
FieldTypeValue has no value but the field cannot be null.
Error message
FieldTypeValue has no value but the field cannot be null.
What it means
isNullFieldValueFromProto checks a decoded proto FieldValue: if the proto message has no value set (hasNonNullValue false) but the corresponding Beam schema FieldType is not nullable, it throws this RuntimeException. It protects the invariant that non-nullable schema fields must always have a value on the wire.
Source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/SchemaTranslation.java:622
.setLogicalTypeValue(logicalTypeToProto(FieldType.INT64, fieldType, value))
.build();
case DECIMAL:
return builder
.setLogicalTypeValue(logicalTypeToProto(FieldType.BYTES, fieldType, value))
.build();
case LOGICAL_TYPE:
return builder
.setLogicalTypeValue(logicalTypeToProto(fieldType.getLogicalType(), value))
.build();
default:
return builder.setAtomicValue(primitiveRowFieldToProto(fieldType, value)).build();
}
}
/** Returns if the given field is null and throws exception if it is and can't be. */
static boolean isNullFieldValueFromProto(FieldType fieldType, boolean hasNonNullValue) {
if (!hasNonNullValue && !fieldType.getNullable()) {
throw new RuntimeException("FieldTypeValue has no value but the field cannot be null.");
}
return !hasNonNullValue;
}
static Object fieldValueFromProto(FieldType fieldType, SchemaApi.FieldValue value) {
switch (fieldType.getTypeName()) {
case ARRAY:
if (isNullFieldValueFromProto(fieldType, value.hasArrayValue())) {
return null;
}
return arrayValueFromProto(fieldType.getCollectionElementType(), value.getArrayValue());
case ITERABLE:
if (isNullFieldValueFromProto(fieldType, value.hasIterableValue())) {
return null;
}
return iterableValueFromProto(
fieldType.getCollectionElementType(), value.getIterableValue());
case MAP:View on GitHub (pinned to 12126d8942)
Solutions
- Make the field nullable in the reading schema to match the data.
- Re-encode the data with values present for every non-nullable field.
- Align the schema used for decoding with the schema captured at write time (store schema alongside data).
- Filter/repair records missing values before decoding (e.g. provide defaults via a map step).
Example fix
// before
Schema.Field field = Schema.Field.of("name", FieldType.STRING);
// after
Schema.Field field = Schema.Field.of("name", FieldType.STRING.withNullable(true)); Defensive patterns
Strategy: validation
Validate before calling
if (!fieldType.getNullable()) { /* require every decoded FieldValue to have hasValue() true before decode */ } Try / catch
try { rowFromProto(proto, schema); } catch (RuntimeException e) { if (e.getMessage().contains("no value but the field cannot be null")) { /* align schema nullability with data */ } else { throw e; } } Prevention
- Store the schema with the data and decode with the same schema
- Avoid tightening nullability after data has been written
- Set a value on every FieldValue proto you construct manually
- Run schema-compat checks in schema evolution workflows
When it happens
Trigger: fieldValueFromProto calls isNullFieldValueFromProto on a FieldValue proto where hasValue() is false/unset while the target FieldType.getNullable() is false — e.g. proto produced by a writer that allowed nulls, reader schema says non-nullable.
Common situations: Schema evolution: field was nullable when the data was written, later tightened to non-nullable before decoding; proto FieldValue constructed programmatically without setting a value; deserializing into a schema from a different (stricter) source.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Could not decode bytes as message
- Null value found for field that doesn't support nulls.
- Most (%s) and least (%s) significant bits value shouldn't be
- Received null value for non-nullable field "{}"
- Null collectionElementType at column
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/d98724f9650f5032.
Report an issue: GitHub.