{"record":{"id":"f6b274819f7d0034","repo":"apache/beam","slug":"method-s-should-not-have-return-type-runtimevalueprovider","errorCode":null,"errorMessage":"Method %s should not have return type RuntimeValueProvider, use ValueProvider instead.","messagePattern":"Method (.+?) should not have return type RuntimeValueProvider, use ValueProvider instead\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/options/ProxyInvocationHandler.java","lineNumber":629,"sourceCode":"      throw new RuntimeException(\"Unable to parse representation\", e);\n    }\n  }\n\n  /**\n   * Returns a default value for the method based upon {@code @Default} metadata on the getter to\n   * return values. If there is no {@code @Default} annotation on the getter, then a <a href=\n   * \"https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html\">default</a> as per\n   * the Java Language Specification for the expected return type is returned.\n   *\n   * @param proxy The proxy object for which we are attempting to get the default.\n   * @param method The getter method that was invoked.\n   * @return The default value from an {@link Default} annotation if present, otherwise a default\n   *     value as per the Java Language Specification.\n   */\n  @SuppressWarnings({\"unchecked\", \"rawtypes\"})\n  private Object getDefault(PipelineOptions proxy, Method method) {\n    if (method.getReturnType().equals(RuntimeValueProvider.class)) {\n      throw new RuntimeException(\n          String.format(\n              \"Method %s should not have return type \"\n                  + \"RuntimeValueProvider, use ValueProvider instead.\",\n              method.getName()));\n    }\n    if (method.getReturnType().equals(StaticValueProvider.class)) {\n      throw new RuntimeException(\n          String.format(\n              \"Method %s should not have return type \"\n                  + \"StaticValueProvider, use ValueProvider instead.\",\n              method.getName()));\n    }\n    @Nullable Object defaultObject = null;\n    for (Annotation annotation : method.getAnnotations()) {\n      defaultObject = returnDefaultHelper(annotation, proxy, method);\n      if (defaultObject != null) {\n        break;\n      }","sourceCodeStart":611,"sourceCodeEnd":647,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/options/ProxyInvocationHandler.java#L611-L647","documentation":"PipelineOptions getter methods must declare the interface ValueProvider, not concrete implementations. ProxyInvocationHandler.getDefault rejects getters whose return type is exactly RuntimeValueProvider, since RuntimeValueProvider is an internal runtime type that users should never reference directly.","triggerScenarios":"Declaring a custom PipelineOptions interface with a getter like `RuntimeValueProvider<String> getFoo();` — detected when the default value is computed during proxy method invocation (called via ValueProvider.value() resolution).","commonSituations":"Copy-pasting from internal Beam code when defining custom options; IDE auto-completing to RuntimeValueProvider; misunderstanding that RuntimeValueProvider is the runtime implementation rather than the interface to declare.","solutions":["Change the getter's return type to ValueProvider<T>.","Rebuild/re-run; the runtime will return a RuntimeValueProvider behind the ValueProvider interface automatically.","Never reference RuntimeValueProvider or StaticValueProvider in PipelineOptions interface definitions."],"exampleFix":"// before\ninterface MyOptions extends PipelineOptions {\n  RuntimeValueProvider<String> getInput();\n}\n// after\ninterface MyOptions extends PipelineOptions {\n  @Default.String(\"in\")\n  ValueProvider<String> getInput();\n}","handlingStrategy":"validation","validationCode":"// Fail fast at startup: scan custom options interfaces\nfor (Method m : MyOptions.class.getMethods()) {\n  if (m.getReturnType() == RuntimeValueProvider.class) {\n    throw new IllegalArgumentException(m.getName() + \" must return ValueProvider\");\n  }\n}","typeGuard":"static boolean usesConcreteValueProvider(Class<? extends PipelineOptions> opts) {\n  return java.util.Arrays.stream(opts.getMethods())\n      .anyMatch(m -> m.getReturnType() == RuntimeValueProvider.class);\n}","tryCatchPattern":null,"preventionTips":["Always declare ValueProvider<T> in options interfaces, never concrete implementations.","Never import RuntimeValueProvider/StaticValueProvider into options interface files.","Use @Default annotations with ValueProvider getters for defaults."],"tags":["java","apache-beam","pipeline-options","valueprovider","api-misuse"],"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-14T16:17:12.679Z"}