apache/beam · error · ValueError

source_info must a three tuple where firstitem of the tuple…

Error message

source_info must a three tuple where firstitem of the tuple gives a iobase.BoundedSource. Received: %r

What it means

In assert_sources_equal_reference_source, each entry in sources_info must be a three-element tuple whose first element is an iobase.BoundedSource. Beam raises ValueError for any entry failing this shape, since it unpacks each tuple to read and split the source during comparison.

Solutions

  1. Make each sources_info entry a 3-tuple: (bounded_source, read_options, desired_bundle_size)
  2. Verify each first element subclasses iobase.BoundedSource
  3. Remove or fix malformed entries in the list
  4. Use a consistent helper in tests that always builds the 3-tuple

Example fix

// before
assert_sources_equal_reference_source(ref, [(src, options)])
// after
assert_sources_equal_reference_source(ref, [(src, options, 1000)])
Defensive patterns

Strategy: type-guard

Validate before calling

from apache_beam.io import iobase
assert all(isinstance(s, tuple) and len(s) == 3 and isinstance(s[0], iobase.BoundedSource) for s in sources_info)

Type guard

def is_valid_source_info(info):
    return isinstance(info, tuple) and len(info) == 3 and isinstance(info[0], iobase.BoundedSource)

Try / catch

try:
    source_test_utils.assert_sources_equal_reference_source(ref, sources)
except ValueError as e:
    logger.error('Bad candidate source entry: %s', e)

Prevention

When it happens

Trigger: Passing (source, options) two-tuples, lists, or non-BoundedSource objects inside the sources_info list to assert_sources_equal_reference_source.

Common situations: Same as the reference-source variant: forgetting the desired_bundle_size element, or accidentally passing legacy custom sources into a BoundedSource test helper.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

Thrown at sdks/python/apache_beam/io/source_test_utils.py:155

  """

  if not (isinstance(reference_source_info, tuple) and
          len(reference_source_info) == 3 and
          isinstance(reference_source_info[0], iobase.BoundedSource)):
    raise ValueError(
        'reference_source_info must a three-tuple where first'
        'item of the tuple gives a '
        'iobase.BoundedSource. Received: %r' % reference_source_info)
  reference_records = read_from_source(*reference_source_info)

  source_records = []
  for source_info in sources_info:
    assert isinstance(source_info, tuple)
    assert len(source_info) == 3
    if not (isinstance(source_info, tuple) and len(source_info) == 3 and
            isinstance(source_info[0], iobase.BoundedSource)):
      raise ValueError(
          'source_info must a three tuple where first'
          'item of the tuple gives a '
          'iobase.BoundedSource. Received: %r' % source_info)
    if (type(reference_source_info[0].default_output_coder())
        != type(source_info[0].default_output_coder())):
      raise ValueError(
          'Reference source %r and the source %r must use the same coder. '
          'They are using %r and %r respectively instead.' % (
              reference_source_info[0],
              source_info[0],
              type(reference_source_info[0].default_output_coder()),
              type(source_info[0].default_output_coder())))
    source_records.extend(read_from_source(*source_info))

  if len(reference_records) != len(source_records):
    raise ValueError(
        'Reference source must produce the same number of records as the '
        'list of sources. Number of records were %d and %d instead.' %

View on GitHub (pinned to 12126d8942)