apache/beam · error · java.lang.RuntimeException
Aliased enumerations not currently supported.
Error message
Aliased enumerations not currently supported.
What it means
When translating a proto ENUM field into a Beam EnumerationType logical type, the translator builds a name->number map from the enum's values. Protobuf's `allow_alias` option lets two enum value names share the same number; since the Beam enumeration map cannot represent two names for one number, the translator throws a RuntimeException.
Solutions
- Remove `option allow_alias = true;` from the enum and give each value a distinct number (keep the canonical name, drop the alias).
- Map the enum field to a plain string/int Beam field instead of EnumerationType (pre-process or use a custom translation).
- Change the field's type in a wrapper message consumed by Beam so it no longer uses the aliased enum.
Example fix
// before
enum Status {
option allow_alias = true;
ACTIVE = 0;
ENABLED = 0; // alias -> RuntimeException
}
// after
enum Status {
ACTIVE = 0;
ENABLED = 1; // distinct numbers
} Defensive patterns
Strategy: validation
Validate before calling
// Java: detect aliased enums before schema translation
static boolean hasAliases(Descriptors.EnumDescriptor e) {
Set<Integer> nums = new HashSet<>();
for (Descriptors.EnumValueDescriptor v : e.getValues()) {
if (!nums.add(v.getNumber())) return true;
}
return false;
} Try / catch
try { Schema s = ProtoSchemaTranslator.getSchema(descriptor); } catch (RuntimeException e) { if ("Aliased enumerations not currently supported.".equals(e.getMessage())) { /* fall back to int-typed field or fix proto */ } else throw e; } Prevention
- Ban `option allow_alias = true;` in protos consumed by Beam (lint with protoc/Buf rules).
- Resolve aliases at proto review time by assigning unique numbers to renamed values.
- Test schema inference over all enum-bearing messages in CI.
When it happens
Trigger: getSchema/beamFieldTypeFromSingularProtoField encounters a proto field whose enum type was declared with `option allow_alias = true;` so at least two EnumValueDescriptors share the same number.
Common situations: Legacy protos using allow_alias for backwards-compatible renames (e.g. OLD_NAME = 1; NEW_NAME = 1); importing shared company protos that use aliases into a Beam pipeline.
Related errors
- Field type not matched.
- Unknown ValueKind
- Unknown ValueKind
- A method marked with SchemaCreate in class
- Any not yet supported
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/69d344c95763289c.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/extensions/protobuf/src/main/java/org/apache/beam/sdk/extensions/protobuf/ProtoSchemaTranslator.java:331
break;
case UINT64:
fieldType = FieldType.logicalType(new UInt64());
break;
case SINT64:
fieldType = FieldType.logicalType(new SInt64());
break;
case FIXED64:
fieldType = FieldType.logicalType(new Fixed64());
break;
case SFIXED64:
fieldType = FieldType.logicalType(new SFixed64());
break;
case ENUM:
Map<String, Integer> enumValues = Maps.newHashMap();
for (EnumValueDescriptor enumValue : protoFieldDescriptor.getEnumType().getValues()) {
if (enumValues.putIfAbsent(enumValue.getName(), enumValue.getNumber()) != null) {
throw new RuntimeException("Aliased enumerations not currently supported.");
}
}
fieldType = FieldType.logicalType(EnumerationType.create(enumValues));
break;
case MESSAGE:
case GROUP:
String fullName = protoFieldDescriptor.getMessageType().getFullName();
switch (fullName) {
case "google.protobuf.Timestamp":
fieldType = FieldType.logicalType(new NanosInstant());
break;
case "google.protobuf.Int32Value":
case "google.protobuf.UInt32Value":
case "google.protobuf.Int64Value":
case "google.protobuf.UInt64Value":
case "google.protobuf.FloatValue":
case "google.protobuf.DoubleValue":
case "google.protobuf.StringValue":View on GitHub (pinned to 12126d8942)