{"record":{"id":"69d344c95763289c","repo":"apache/beam","slug":"aliased-enumerations-not-currently-supported","errorCode":null,"errorMessage":"Aliased enumerations not currently supported.","messagePattern":"Aliased enumerations not currently supported\\.","errorType":"exception","errorClass":"java.lang.RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/protobuf/src/main/java/org/apache/beam/sdk/extensions/protobuf/ProtoSchemaTranslator.java","lineNumber":331,"sourceCode":"        break;\n      case UINT64:\n        fieldType = FieldType.logicalType(new UInt64());\n        break;\n      case SINT64:\n        fieldType = FieldType.logicalType(new SInt64());\n        break;\n      case FIXED64:\n        fieldType = FieldType.logicalType(new Fixed64());\n        break;\n      case SFIXED64:\n        fieldType = FieldType.logicalType(new SFixed64());\n        break;\n\n      case ENUM:\n        Map<String, Integer> enumValues = Maps.newHashMap();\n        for (EnumValueDescriptor enumValue : protoFieldDescriptor.getEnumType().getValues()) {\n          if (enumValues.putIfAbsent(enumValue.getName(), enumValue.getNumber()) != null) {\n            throw new RuntimeException(\"Aliased enumerations not currently supported.\");\n          }\n        }\n        fieldType = FieldType.logicalType(EnumerationType.create(enumValues));\n        break;\n      case MESSAGE:\n      case GROUP:\n        String fullName = protoFieldDescriptor.getMessageType().getFullName();\n        switch (fullName) {\n          case \"google.protobuf.Timestamp\":\n            fieldType = FieldType.logicalType(new NanosInstant());\n            break;\n          case \"google.protobuf.Int32Value\":\n          case \"google.protobuf.UInt32Value\":\n          case \"google.protobuf.Int64Value\":\n          case \"google.protobuf.UInt64Value\":\n          case \"google.protobuf.FloatValue\":\n          case \"google.protobuf.DoubleValue\":\n          case \"google.protobuf.StringValue\":","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/protobuf/src/main/java/org/apache/beam/sdk/extensions/protobuf/ProtoSchemaTranslator.java#L313-L349","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nenum Status {\n  option allow_alias = true;\n  ACTIVE = 0;\n  ENABLED = 0; // alias -> RuntimeException\n}\n// after\nenum Status {\n  ACTIVE = 0;\n  ENABLED = 1; // distinct numbers\n}","handlingStrategy":"validation","validationCode":"// Java: detect aliased enums before schema translation\nstatic boolean hasAliases(Descriptors.EnumDescriptor e) {\n  Set<Integer> nums = new HashSet<>();\n  for (Descriptors.EnumValueDescriptor v : e.getValues()) {\n    if (!nums.add(v.getNumber())) return true;\n  }\n  return false;\n}","typeGuard":null,"tryCatchPattern":"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; }","preventionTips":["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."],"tags":["protobuf","enum","java","beam-schema"],"backgroundTag":"unsupported-enum-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}