apache/beam · error · IllegalArgumentException
Expected getter for property [%s] to be marked with @%s on a
Error message
Expected getter for property [%s] to be marked with @%s on all %s, found only on %s
What it means
Thrown when a property getter is expected to carry a given annotation (e.g. @Default, @Hidden, @Validation) on every interface that declares it, but the annotation is present on only some declarations. Beam requires annotation consistency across the hierarchy to derive reliable property metadata.
Source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java:1405
String.format(
"%n - Method [%s] has multiple definitions %s",
errDef.method.getName(), errDef.collidingMethods));
}
throw new IllegalArgumentException(errorBuilder.toString());
}
}
private static class InconsistentlyAnnotatedGetters {
PropertyDescriptor descriptor;
Iterable<String> getterClassNames;
Iterable<String> gettersWithTheAnnotationClassNames;
}
private static void throwForGettersWithInconsistentAnnotation(
List<InconsistentlyAnnotatedGetters> getters, Class<? extends Annotation> annotationClass) {
if (getters.size() == 1) {
InconsistentlyAnnotatedGetters getter = getters.get(0);
throw new IllegalArgumentException(
String.format(
"Expected getter for property [%s] to be marked with @%s on all %s, "
+ "found only on %s",
getter.descriptor.getName(),
annotationClass.getSimpleName(),
getter.getterClassNames,
getter.gettersWithTheAnnotationClassNames));
} else if (getters.size() > 1) {
StringBuilder errorBuilder =
new StringBuilder(
String.format(
"Property getters are inconsistently marked with @%s:",
annotationClass.getSimpleName()));
for (InconsistentlyAnnotatedGetters getter : getters) {
errorBuilder.append(
String.format(
"%n - Expected for property [%s] to be marked on all %s, " + "found only on %s",
getter.descriptor.getName(),View on GitHub (pinned to 12126d8942)
Solutions
- Copy the named annotation onto the getter declarations listed as missing it.
- Or remove the annotation everywhere so the property is uniformly unannotated.
- Search the codebase for all declarations of the getter name and keep them identical.
Example fix
// before
interface A extends PipelineOptions { @Default.String("x") String getFoo(); }
interface B extends A { String getFoo(); }
// after
interface A extends PipelineOptions { @Default.String("x") String getFoo(); }
interface B extends A { @Default.String("x") String getFoo(); } Defensive patterns
Strategy: validation
Validate before calling
for (java.lang.reflect.Method m : MyOptions.class.getMethods()) {
if (m.getName().equals("getFoo")) {
if (m.getAnnotation(org.apache.beam.sdk.options.Default.String.class) == null) {
throw new IllegalStateException("getFoo in " + m.getDeclaringClass() + " missing @Default.String");
}
}
} Try / catch
try {
PipelineOptionsFactory.fromArgs(args).as(MyOptions.class);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("to be marked with @")) { /* copy the annotation to the listed declarations */ }
throw e;
} Prevention
- When overriding a getter, copy all its annotations verbatim
- Search all declarations of a getter before editing its annotations
- Prefer single-declaration inheritance over per-interface re-declaration
When it happens
Trigger: PipelineOptionsFactory registration when throwForGettersWithInconsistentAnnotation finds one InconsistentlyAnnotatedGetters: getFoo() is annotated with e.g. @Default.String in sub-interface A but not in sub-interface B, both contributing the same property.
Common situations: Overriding a getter in a sub-interface without copying its annotation; adding an annotation to a base interface while stale un-annotated overrides exist elsewhere.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- Property [%s] is marked with contradictory annotations. Foun
- Property getters are inconsistently marked with @%s:
- All inherited interfaces of [%s] should inherit from the Pip
- Method [%s] has multiple definitions %s with different retur
- Interface [%s] has Methods with multiple definitions with di
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/4a6ec93d980236a1.
Report an issue: GitHub.