apache/beam · error · java.lang.RuntimeException

Field type not matched.

Error message

Field type not matched.

What it means

The switch over proto field types in beamFieldTypeFromSingularProtoField has a default branch that throws RuntimeException("Field type not matched.") — reached when the field's Java proto Type (the switch subject) is not one of the handled cases. It is a defensive fall-through indicating the translator does not know how to map this proto field's type to a Beam FieldType.

Solutions

  1. Identify the proto field's type (from the message text of the exception context) and replace it with a supported type in the .proto file.
  2. Upgrade (or pin) the Beam version so the translator handles the field type; check Beam JIRA for the missing mapping.
  3. Pre-convert the unsupported field to bytes/string in a wrapper message before schema translation.
Defensive patterns

Strategy: try-catch

Validate before calling

// Java: check the proto field's type is a kind the translator handles (scalars, ENUM, MESSAGE)
static boolean isSupportedKind(Descriptors.FieldDescriptor.Type t) {
  switch (t) {
    case GROUP: return false; // extend with any other unhandled kinds discovered
    default: return true;
  }
}

Try / catch

try { Schema s = ProtoSchemaTranslator.getSchema(descriptor); } catch (RuntimeException e) { if ("Field type not matched.".equals(e.getMessage())) { /* translate that field to bytes/string manually or upgrade Beam */ } else throw e; }

Prevention

When it happens

Trigger: A proto field whose Java type constant falls outside every handled case in the switch over protoFieldDescriptor (e.g. unhandled scalar/type mapping introduced by newer protobuf versions or GROUP-like types reaching the singular-field path).

Common situations: Upgrading protobuf-java/runtime so new type kinds appear; exotic field descriptors (extension ranges, groups) reaching schema translation; internal API misuse calling beamFieldTypeFromSingularProtoField with a descriptor type it wasn't designed for.

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


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/d2c5192dd0d80aed. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/extensions/protobuf/src/main/java/org/apache/beam/sdk/extensions/protobuf/ProtoSchemaTranslator.java:366

          case "google.protobuf.DoubleValue":
          case "google.protobuf.StringValue":
          case "google.protobuf.BoolValue":
          case "google.protobuf.BytesValue":
            fieldType =
                beamFieldTypeFromSingularProtoField(
                    protoFieldDescriptor.getMessageType().findFieldByNumber(1));
            break;
          case "google.protobuf.Duration":
            fieldType = FieldType.logicalType(new NanosDuration());
            break;
          case "google.protobuf.Any":
            throw new UnsupportedOperationException("Any not yet supported");
          default:
            fieldType = FieldType.row(getSchema(protoFieldDescriptor.getMessageType()));
        }
        break;
      default:
        throw new RuntimeException("Field type not matched.");
    }

    if (isNullable(protoFieldDescriptor)) {
      fieldType = fieldType.withNullable(true);
    }

    return fieldType;
  }

  private static Schema.Options.Builder getFieldOptions(FieldDescriptor fieldDescriptor) {
    return getOptions(SCHEMA_OPTION_FIELD_PREFIX, fieldDescriptor.getOptions().getAllFields());
  }

  private static Schema.Options.Builder getSchemaOptions(Descriptors.Descriptor descriptor) {
    return getOptions(SCHEMA_OPTION_MESSAGE_PREFIX, descriptor.getOptions().getAllFields());
  }

  private static Schema.Options.Builder getOptions(

View on GitHub (pinned to 12126d8942)