{"record":{"id":"27a45d767f52966e","repo":"apache/beam","slug":"coder-registry-has-no-fallback-coder-this-can-happen-if-the","errorCode":null,"errorMessage":"Coder registry has no fallback coder. This can happen if the fast_coders module could not be imported.","messagePattern":"Coder registry has no fallback coder\\. This can happen if the fast_coders module could not be imported\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/coders/typecoders.py","lineNumber":189,"sourceCode":"    typing_to_runner_api(typehint_type)\n    return typehint_type\n\n  def get_coder(self, typehint: Any) -> coders.Coder:\n    if typehint and typehint.__module__ == '__main__':\n      # See https://github.com/apache/beam/issues/21541\n      # TODO(robertwb): Remove once all runners are portable.\n      typehint = getattr(typehint, '__name__', str(typehint))\n    coder = self._coders.get(\n        typehint.__class__\n        if isinstance(typehint, typehints.TypeConstraint) else typehint,\n        None)\n    if isinstance(typehint, typehints.TypeConstraint) and coder is not None:\n      return coder.from_type_hint(typehint, self)\n    if coder is None:\n      # We use the fallback coder when there is no coder registered for a\n      # typehint. For example a user defined class with no coder specified.\n      if not hasattr(self, '_fallback_coder'):\n        raise RuntimeError(\n            'Coder registry has no fallback coder. This can happen if the '\n            'fast_coders module could not be imported.')\n      if isinstance(typehint, typehints.IterableTypeConstraint):\n        return coders.IterableCoder.from_type_hint(typehint, self)\n      elif isinstance(typehint, typehints.ListConstraint):\n        return coders.ListCoder.from_type_hint(typehint, self)\n      elif typehints.is_nullable(typehint):\n        return coders.NullableCoder.from_type_hint(typehint, self)\n      elif typehint is None:\n        # In some old code, None is used for Any.\n        # TODO(robertwb): Clean this up.\n        pass\n      elif typehint is object or typehint == typehints.Any:\n        # We explicitly want the fallback coder.\n        pass\n      elif isinstance(typehint, typehints.TypeVariable):\n        # TODO(robertwb): Clean this up when type inference is fully enabled.\n        pass","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/coders/typecoders.py#L171-L207","documentation":"When no coder is registered for a type hint, the CoderRegistry falls back to a default coder that is installed at import time (typically the fast coders module). If the module-level initialization was skipped or failed (e.g. fast_coders could not be imported), the registry has no _fallback_coder attribute and get_coder raises this RuntimeError.","triggerScenarios":"Calling registry.get_coder(typehint) for an unregistered type when module init failed — typically because the compiled fast_coders C extension is missing or failed to import, or calling get_coder on a manually constructed CoderRegistry() before fallback setup.","commonSituations":"Broken/partial apache_beam installs missing compiled extensions; environments where cython/fast coder wheels are unavailable; tests instantiating a fresh registry without invoking the setup that assigns the fallback.","solutions":["Reinstall apache_beam from a wheel so compiled fast_coders extensions are present (pip install --force-reinstall apache_beam).","Check import of apache_beam.coders.coders_fast for ImportError and fix the underlying extension issue.","Avoid hand-instantiating CoderRegistry; use the module-level `registry` in typecoders which has the fallback set.","As a workaround, register an explicit coder for the typehint so the fallback is never consulted."],"exampleFix":"// before\nfrom apache_beam.coders.typecoders import CoderRegistry\ncoder = CoderRegistry().get_coder(my_typehint)\n// after\nfrom apache_beam.coders import typecoders\ncoder = typecoders.registry.get_coder(my_typehint)  # fallback initialized at import","handlingStrategy":"fallback","validationCode":"from apache_beam.coders import coders_fast  # ImportError means fast coders missing\nregistry_has_fallback = hasattr(typecoders.registry, '_fallback_coder')","typeGuard":"def fallback_available() -> bool:\n    return hasattr(typecoders.registry, '_fallback_coder')","tryCatchPattern":"try:\n    coder = registry.get_coder(typehint)\nexcept RuntimeError as e:\n    if 'no fallback coder' in str(e):\n        reinstall_beam_or_register_explicit_coder(typehint)\n    else:\n        raise","preventionTips":["Install apache_beam from official wheels so C extensions build/import.","Verify `import apache_beam.coders.coders_fast` works after install.","Use the shared module-level registry instead of hand-built instances.","Register explicit coders for user types so fallback isn't needed."],"tags":["python","coders","registry","installation"],"backgroundTag":"module-init-failed","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"}