{"record":{"id":"d67716ff1781800e","repo":"apache/beam","slug":"valueprovider-is-accessible-implemented-in-derived-classes","errorCode":null,"errorMessage":"ValueProvider.is_accessible implemented in derived classes","messagePattern":"ValueProvider\\.is_accessible implemented in derived classes","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/options/value_provider.py","lineNumber":47,"sourceCode":"from apache_beam import error\n\n__all__ = [\n    'ValueProvider',\n    'StaticValueProvider',\n    'RuntimeValueProvider',\n    'NestedValueProvider',\n    'check_accessible',\n]\n\n\nclass ValueProvider(object):\n  \"\"\"Base class that all other ValueProviders must implement.\n  \"\"\"\n  def is_accessible(self):\n    \"\"\"Whether the contents of this ValueProvider is available to routines\n    that run at graph construction time.\n    \"\"\"\n    raise NotImplementedError(\n        'ValueProvider.is_accessible implemented in derived classes')\n\n  def get(self):\n    \"\"\"Return the value wrapped by this ValueProvider.\n    \"\"\"\n    raise NotImplementedError(\n        'ValueProvider.get implemented in derived classes')\n\n\nclass StaticValueProvider(ValueProvider):\n  \"\"\"StaticValueProvider is an implementation of ValueProvider that allows\n  for a static value to be provided.\n  \"\"\"\n  def __init__(self, value_type, value):\n    \"\"\"\n    Args:\n        value_type: Type of the static value\n        value: Static value","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/options/value_provider.py#L29-L65","documentation":"ValueProvider is an abstract base class; is_accessible must be implemented by subclasses (StaticValueProvider, RuntimeValueProvider, etc.). Instantiating a custom ValueProvider without overriding is_accessible makes graph-construction code hit this NotImplementedError.","triggerScenarios":"Subclassing ValueProvider directly and not overriding is_accessible, then calling vp.is_accessible() at pipeline construction time.","commonSituations":"Writing a custom ValueProvider for deferred parameters and forgetting one of the abstract methods; or a library upgrade changing the interface.","solutions":["Override is_accessible() (and get()) in your ValueProvider subclass.","Use StaticValueProvider or RuntimeValueProvider instead of subclassing from scratch.","Call is_accessible only on concrete ValueProvider instances."],"exampleFix":"# before\nclass MyVP(ValueProvider):\n    pass\n# after\nclass MyVP(ValueProvider):\n    def is_accessible(self):\n        return self._value is not None\n    def get(self):\n        return self._value","handlingStrategy":"try-catch","validationCode":"if type(vp) is ValueProvider: raise TypeError('use a concrete ValueProvider subclass')","typeGuard":"def is_concrete_value_provider(vp) -> bool:\n    return isinstance(vp, ValueProvider) and type(vp) is not ValueProvider and vp.is_accessible.__func__ is not ValueProvider.is_accessible","tryCatchPattern":"try:\n    accessible = vp.is_accessible()\nexcept NotImplementedError:\n    accessible = True  # assume accessible for legacy providers","preventionTips":["Subclass StaticValueProvider/RuntimeValueProvider rather than ValueProvider.","Cover custom providers with unit tests calling both is_accessible and get."],"tags":["apache-beam","python","abstract-method"],"backgroundTag":"abstract-method-not-implemented","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"}