apache/beam · error · ValueError

hdfs_host is not set

Error message

hdfs_host is not set

What it means

After reading connection settings from pipeline options, HadoopFileSystem validates each required field. A missing hdfs_host raises ValueError 'hdfs_host is not set' because no HDFS namenode host was configured.

Source

Thrown at sdks/python/apache_beam/io/hadoopfilesystem.py:134

          'Failed to import hdfs. You can ensure it is '
          'installed by installing the hadoop beam extra')
    logging.getLogger('hdfs.client').setLevel(logging.WARN)
    if pipeline_options is None:
      raise ValueError('pipeline_options is not set')
    if isinstance(pipeline_options, PipelineOptions):
      hdfs_options = pipeline_options.view_as(HadoopFileSystemOptions)
      hdfs_host = hdfs_options.hdfs_host
      hdfs_port = hdfs_options.hdfs_port
      hdfs_user = hdfs_options.hdfs_user
      self._full_urls = hdfs_options.hdfs_full_urls
    else:
      hdfs_host = pipeline_options.get('hdfs_host')
      hdfs_port = pipeline_options.get('hdfs_port')
      hdfs_user = pipeline_options.get('hdfs_user')
      self._full_urls = pipeline_options.get('hdfs_full_urls', False)

    if hdfs_host is None:
      raise ValueError('hdfs_host is not set')
    if hdfs_port is None:
      raise ValueError('hdfs_port is not set')
    if hdfs_user is None:
      raise ValueError('hdfs_user is not set')
    if not isinstance(self._full_urls, bool):
      raise ValueError(
          'hdfs_full_urls should be bool, got: %s', self._full_urls)
    self._hdfs_client = hdfs.InsecureClient(
        'http://%s:%s' % (hdfs_host, str(hdfs_port)), user=hdfs_user)

  @classmethod
  def scheme(cls):
    return 'hdfs'

  def _parse_url(self, url):
    """Verifies that url begins with hdfs:// prefix, strips it and adds a
    leading /.

View on GitHub (pinned to 12126d8942)

Solutions

  1. Set the --hdfs_host flag or add 'hdfs_host': '<namenode>' to the options.
  2. Use HadoopFileSystemOptions with hdfs_host populated and view_as it.
  3. Double-check key spelling when passing a raw dict ('hdfs_host' exactly).
  4. Fail fast in your launcher by asserting options contain hdfs_host before starting the pipeline.

Example fix

// before
PipelineOptions(['--hdfs_port=50070', '--hdfs_user=hduser'])
// after
PipelineOptions(['--hdfs_host=namenode.example.com', '--hdfs_port=50070', '--hdfs_user=hduser'])
Defensive patterns

Strategy: validation

Validate before calling

def require_hdfs_host(opts):
    v = (opts.get('hdfs_host') if isinstance(opts, dict)
         else opts.view_as(HadoopFileSystemOptions).hdfs_host)
    if not v:
        raise ValueError('Set --hdfs_host before launching')
    return v

Type guard

None

Try / catch

try:
    fs = HadoopFileSystem(pipeline_options=opts)
except ValueError as e:
    if 'hdfs_host is not set' in str(e):
        raise SystemExit('Add --hdfs_host=<namenode> to pipeline options')
    raise

Prevention

When it happens

Trigger: Initializing HadoopFileSystem with options lacking the 'hdfs_host' key / --hdfs_host flag; typo like 'hdfs_hostname' in a dict-based options mapping.

Common situations: Partial HadoopFileSystemOptions configuration; environment differences where config was provided locally but not on workers; dict passed without the exact key names.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/ae65753530b1aa6c. Report an issue: GitHub.