apache/beam · error · RuntimeException
Getter has wrong prefix <method>
Error message
Getter has wrong prefix <method>
What it means
Thrown by FieldValueTypeInformation.forGetter when a method is being introspected as a getter but its name does not start with the recognized prefixes "get" or "is". The schema framework only accepts JavaBean-style getters, so any other method passed as a getter fails.
Source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/FieldValueTypeInformation.java:206
if (fieldDescription == null) {
return null;
}
return fieldDescription.value();
}
public static FieldValueTypeInformation forGetter(Method method, int index) {
return forGetter(null, method, index);
}
public static FieldValueTypeInformation forGetter(
@Nullable TypeDescriptor<?> typeDescriptor, Method method, int index) {
String name;
if (method.getName().startsWith("get")) {
name = ReflectUtils.stripPrefix(method.getName(), "get");
} else if (method.getName().startsWith("is")) {
name = ReflectUtils.stripPrefix(method.getName(), "is");
} else {
throw new RuntimeException("Getter has wrong prefix " + method.getName());
}
TypeDescriptor<?> type =
Optional.ofNullable(typeDescriptor)
.map(td -> (TypeDescriptor) td.resolveType(method.getGenericReturnType()))
// fall back to previous behavior
.orElseGet(() -> TypeDescriptor.of(method.getGenericReturnType()));
boolean nullable = hasNullableReturnType(method);
return new AutoValue_FieldValueTypeInformation.Builder()
.setName(getNameOverride(name, method))
.setNumber(getNumberOverride(index, method))
.setNullable(nullable)
.setType(type)
.setRawType(type.getRawType())
.setMethod(method)
.setElementType(getIterableComponentType(type))
.setMapKeyType(getMapKeyType(type))View on GitHub (pinned to 12126d8942)
Solutions
- Rename the method to start with get (or is for boolean return types).
- If the method is not a field getter, exclude it from schema introspection (e.g. make it private or annotate the class schema accordingly).
- Use @SchemaFieldName on a properly-prefixed getter to control the schema field name instead of custom prefixes.
Example fix
// before
public String fetchName() { ... }
// after
public String getName() { ... } Defensive patterns
Strategy: validation
Validate before calling
for (Method m : clazz.getMethods()) { if (m.getParameterCount() == 0 && !m.getName().startsWith("get") && !m.getName().startsWith("is") && !java.lang.reflect.Modifier.isStatic(m.getModifiers())) { /* exclude or rename before registering */ } } Type guard
static boolean isBeanGetter(Method m) { return m.getParameterCount() == 0 && (m.getName().startsWith("get") || m.getName().startsWith("is")) && !m.getReturnType().equals(void.class); } Try / catch
try { schemaOf(clazz); } catch (RuntimeException e) { if (e.getMessage().startsWith("Getter has wrong prefix")) { /* rename method or exclude from schema */ } else { throw e; } } Prevention
- Follow strict JavaBean getter naming (getX/isX for boolean).
- Avoid custom getter prefixes in schema'd classes.
- Keep non-property helper methods private or static.
When it happens
Trigger: Passing a method whose name lacks the get/is prefix to forGetter; schema discovery routing a non-getter method (e.g. calculateTotal or fetchName) into getter handling.
Common situations: Custom getter prefixes (e.g. `fetch`, `retrieve`) in bean-like classes; fluent-style getters returning this without prefix; methods inherited from interfaces that don't follow JavaBean conventions.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Setter has wrong prefix <method>
- Setter methods should take a single argument <method>
- @SchemaFieldNumber can only be used on getters in Java Beans
- @SchemaFieldName can only be used on getters in Java Beans.
- Could not determine array parameter type for field.
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/09344fd2a798eccb.
Report an issue: GitHub.