apache/beam · error · RuntimeValueProviderError
.get() not called from a runtime context
Error message
%s.get() not called from a runtime context
What it means
RuntimeValueProvider.get() only works at pipeline runtime when runtime options have been set. Calling it at graph-construction time (before the pipeline runs) raises RuntimeValueProviderError because the actual value is not yet known.
Solutions
- Only call get() inside worker-time code (DoFn.process) after runtime options are set
- Check value_provider.is_accessible() before calling get() and provide a default otherwise
- Use StaticValueProvider for values known at construction time
- Pass required options at runtime (e.g. --my_option=value) so the provider becomes accessible
Example fix
// before name = beam_options.view_as(MyOptions).name.get() # at graph build time // after name = beam_options.view_as(MyOptions).name # pass the provider; call .get() inside DoFn.process, guarded by is_accessible()
Defensive patterns
Strategy: type-guard
Validate before calling
if not vp.is_accessible():
raise RuntimeError('option not available yet; run at pipeline runtime') Type guard
def is_readable(vp):
return vp.is_accessible() Try / catch
try:
value = vp.get()
except RuntimeValueProviderError:
value = default_value Prevention
- Only call get() inside DoFn.process or after pipeline start
- Prefer StaticValueProvider for build-time-known values
- Always provide defaults for options
- Never dereference RuntimeValueProvider during graph construction
When it happens
Trigger: Calling value_provider.get() on a RuntimeValueProvider in the main program before Pipeline.run(); accessing .get() in a DoFn setup-free path where runtime options weren't populated (e.g. running without Dataflow template context).
Common situations: Reading option values during pipeline construction; using RuntimeValueProvider in DirectRunner runs without passing pipeline options at execution time; calling get() in tests.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- not accessible
- Value only available at runtime, but accessed from a…
- A BigQuery table or a query must be specified
- A cluster_identifier should be Optional[Union[str…
- A context manager constructor (not a fully constructed…
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/47526983749210fd.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/options/value_provider.py:120
self.value_type = value_type
def is_accessible(self):
return RuntimeValueProvider.runtime_options is not None
@classmethod
def get_value(cls, option_name, value_type, default_value):
if not RuntimeValueProvider.runtime_options:
return default_value
candidate = RuntimeValueProvider.runtime_options.get(option_name)
if candidate:
return value_type(candidate)
else:
return default_value
def get(self):
if RuntimeValueProvider.runtime_options is None:
raise error.RuntimeValueProviderError(
'%s.get() not called from a runtime context' % self)
return RuntimeValueProvider.get_value(
self.option_name, self.value_type, self.default_value)
@classmethod
def set_runtime_options(cls, pipeline_options):
RuntimeValueProvider.runtime_options = pipeline_options
RuntimeValueProvider.experiments = RuntimeValueProvider.get_value(
'experiments', set, set())
def __str__(self):
return '%s(option: %s, type: %s, default_value: %s)' % (
self.__class__.__name__,
self.option_name,
self.value_type.__name__,
repr(self.default_value))
View on GitHub (pinned to 12126d8942)