{"record":{"id":"7b55955e17bad9b3","repo":"apache/beam","slug":"label-string-format-message-args","errorCode":null,"errorMessage":"label + \": \" + String.format(message, args)","messagePattern":"label \\+ \": \" \\+ String\\.format\\(message, args\\)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/reflect/DoFnSignatures.java","lineNumber":2502,"sourceCode":"    }\n\n    ErrorReporter forMethod(Class<? extends Annotation> annotation, Method method) {\n      return new ErrorReporter(\n          this,\n          String.format(\n              \"@%s %s\", format(annotation), (method == null) ? \"(absent)\" : format(method)));\n    }\n\n    ErrorReporter forParameter(ParameterDescription param) {\n      return new ErrorReporter(\n          this,\n          String.format(\n              \"parameter of type %s at index %s\", format(param.getType()), param.getIndex()));\n    }\n\n    @FormatMethod\n    void throwIllegalArgument(@FormatString String message, Object... args) {\n      throw new IllegalArgumentException(label + \": \" + String.format(message, args));\n    }\n\n    @FormatMethod\n    public void checkArgument(boolean condition, @FormatString String message, Object... args) {\n      if (!condition) {\n        throwIllegalArgument(message, args);\n      }\n    }\n\n    @FormatMethod\n    public void checkNotNull(Object value, @FormatString String message, Object... args) {\n      if (value == null) {\n        throwIllegalArgument(message, args);\n      }\n    }\n  }\n\n  public static StateSpec<?> getStateSpecOrThrow(","sourceCodeStart":2484,"sourceCodeEnd":2520,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/reflect/DoFnSignatures.java#L2484-L2520","documentation":"DoFnSignatures builds IllegalArgumentException messages for invalid DoFn signatures via a @FormatMethod helper that prefixes them with the DoFn class label. The thrown message is 'label: <formatted message>' describing a bad parameter, e.g. an unsupported parameter type at a given index. Beam throws this at pipeline-construction time when a DoFn method signature violates the DoFn processing-method rules.","triggerScenarios":"Declaring a @ProcessElement (or @StartBundle/@FinishBundle) method whose parameter at some index has a type Beam cannot recognize (e.g. wrong order of ProcessContext, BoundedWindow, extra types), so signature analysis calls throwIllegalArgument with 'parameter of type %s at index %s'.","commonSituations":"Migrating DoFns across Beam versions where the allowed parameter list changed; hand-written DoFns with parameters in the wrong order (ProcessContext must come first, BoundedWindow before restrictions); typos in types like using a custom context class instead of DoFn.ProcessContext.","solutions":["Fix the DoFn method signature so parameters follow the allowed order/types: (ProcessContext, BoundedWindow, RestrictionT, WatermarkEstimatorT, ...)","Read the full message: it names the offending type and its parameter index; correct that exact parameter","Use @ProcessElement with 'OutputReceiver<OutputT>' (or ProcessContext) rather than custom receiver types","Check the Beam version's DoFnSignatures javadoc for the accepted parameter kinds"],"exampleFix":"// before\nclass MyFn extends DoFn<String, String> {\n  @ProcessElement\n  public void process(BoundedWindow window, ProcessContext ctx) { ... }\n}\n\n// after\nclass MyFn extends DoFn<String, String> {\n  @ProcessElement\n  public void process(ProcessContext ctx, BoundedWindow window) { ... }\n}","handlingStrategy":"validation","validationCode":"// Validate DoFn method params before submitting the pipeline\nList<Class<?>> allowed = List.of(DoFn.ProcessContext.class, DoFn.OutputReceiver.class,\n    BoundedWindow.class, RestrictionTracker.class, WatermarkEstimator.class);\nfor (Method m : myFn.getClass().getDeclaredMethods()) {\n  if (m.isAnnotationPresent(DoFn.ProcessElement.class)) {\n    for (Class<?> p : m.getParameterTypes()) {\n      if (!allowed.stream().anyMatch(a -> a.isAssignableFrom(p))) {\n        throw new IllegalArgumentException(\"Unsupported DoFn parameter type: \" + p);\n      }\n    }\n  }\n}","typeGuard":"static boolean isValidDoFnParam(Class<?> p) {\n  return DoFn.ProcessContext.class.isAssignableFrom(p)\n      || BoundedWindow.class.isAssignableFrom(p)\n      || DoFn.OutputReceiver.class.isAssignableFrom(p);\n}","tryCatchPattern":null,"preventionTips":["Always put ProcessContext first and BoundedWindow after it in @ProcessElement signatures","Run DoFnSignatures-validated pipelines in unit tests before production","Pin and read the DoFn javadoc for the Beam version in use"],"tags":["java","apache-beam","dofn-signature","illegal-argument"],"backgroundTag":"invalid-argument-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}