{"record":{"id":"be0e68c2408103fb","repo":"apache/beam","slug":"only-a-runtimevalueprovider-or-a-nestedvalueprovider-can","errorCode":null,"errorMessage":"Only a RuntimeValueProvider or a NestedValueProvider can supply a property name.","messagePattern":"Only a RuntimeValueProvider or a NestedValueProvider can supply a property name\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/options/ValueProvider.java","lineNumber":163,"sourceCode":"      if (cachedValue == null) {\n        cachedValue = translator.apply(value.get());\n      }\n      return cachedValue;\n    }\n\n    @Override\n    public boolean isAccessible() {\n      return value.isAccessible();\n    }\n\n    /** Returns the property name associated with this provider. */\n    public String propertyName() {\n      if (value instanceof RuntimeValueProvider) {\n        return ((RuntimeValueProvider) value).propertyName();\n      } else if (value instanceof NestedValueProvider) {\n        return ((NestedValueProvider) value).propertyName();\n      } else {\n        throw new RuntimeException(\n            \"Only a RuntimeValueProvider or a NestedValueProvider can supply\"\n                + \" a property name.\");\n      }\n    }\n\n    @Override\n    public String toString() {\n      if (isAccessible()) {\n        return String.valueOf(get());\n      }\n      return MoreObjects.toStringHelper(this)\n          .add(\"value\", value)\n          .add(\"translator\", translator.getClass().getSimpleName())\n          .toString();\n    }\n\n    @Override\n    public boolean equals(@Nullable Object other) {","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/options/ValueProvider.java#L145-L181","documentation":"NestedValueProvider.propertyName() can only report the underlying property name when the wrapped value is itself a RuntimeValueProvider or another NestedValueProvider. A plain static/serializable value has no pipeline-option property backing it, so a RuntimeException is thrown.","triggerScenarios":"Calling propertyName() on a NestedValueProvider that wraps a static value (e.g. NestedValueProvider.of(StaticValueProvider.of(x), fn)) instead of one derived from a PipelineOptions ValueProvider field.","commonSituations":"Introspecting a value provider to learn which option it maps to, but the provider was constructed from a literal constant rather than from a PipelineOptions getter; common in connector/IO code paths that assume runtime options.","solutions":["Only call propertyName() on providers created from PipelineOptions value-provider fields","Wrap the value in a runtime provider via options.valueProvider(...) instead of a static value","Guard with instanceof RuntimeValueProvider/NestedValueProvider before calling propertyName(), or catch RuntimeException"],"exampleFix":"// before\nString name = myNestedProvider.propertyName(); // throws when backing value is static\n// after\nString name = provider instanceof RuntimeValueProvider || provider instanceof NestedValueProvider\n    ? provider.propertyName() : null;","handlingStrategy":"type-guard","validationCode":"if (!(provider instanceof RuntimeValueProvider) && !(provider instanceof NestedValueProvider)) { /* static value: no property name available */ }","typeGuard":"boolean hasPropertyName(ValueProvider<?> v) { return v instanceof RuntimeValueProvider || v instanceof NestedValueProvider; }","tryCatchPattern":"try { name = provider.propertyName(); } catch (RuntimeException e) { name = null; /* static value */ }","preventionTips":["Build NestedValueProviders only from option-backed providers","Avoid propertyName() introspection on literal/StaticValueProvider values","Document that propertyName() is only meaningful for runtime-derived providers"],"tags":["java","apache-beam","value-provider"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}