{"record":{"id":"e2aa31374088addc","repo":"apache/beam","slug":"reference-source-info-must-a-three-tuple-where-firstitem-of","errorCode":null,"errorMessage":"reference_source_info must a three-tuple where firstitem of the tuple gives a iobase.BoundedSource. Received: %r","messagePattern":"reference_source_info must a three-tuple where firstitem of the tuple gives a iobase\\.BoundedSource\\. Received: %r","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/io/source_test_utils.py","lineNumber":143,"sourceCode":"        (Tuple[~apache_beam.io.iobase.BoundedSource, int, int]):\n      a three-tuple that gives the reference\n      :class:`~apache_beam.io.iobase.BoundedSource`, position to start\n      reading at, and position to stop reading at.\n    sources_info\\\n        (Iterable[Tuple[~apache_beam.io.iobase.BoundedSource, int, int]]):\n      a set of sources. Each source is a three-tuple that is of the same\n      format described above.\n\n  Raises:\n    ValueError: if the set of data produced by the reference source\n      and the given set of sources are not equivalent.\n\n  \"\"\"\n\n  if not (isinstance(reference_source_info, tuple) and\n          len(reference_source_info) == 3 and\n          isinstance(reference_source_info[0], iobase.BoundedSource)):\n    raise ValueError(\n        'reference_source_info must a three-tuple where first'\n        'item of the tuple gives a '\n        'iobase.BoundedSource. Received: %r' % reference_source_info)\n  reference_records = read_from_source(*reference_source_info)\n\n  source_records = []\n  for source_info in sources_info:\n    assert isinstance(source_info, tuple)\n    assert len(source_info) == 3\n    if not (isinstance(source_info, tuple) and len(source_info) == 3 and\n            isinstance(source_info[0], iobase.BoundedSource)):\n      raise ValueError(\n          'source_info must a three tuple where first'\n          'item of the tuple gives a '\n          'iobase.BoundedSource. Received: %r' % source_info)\n    if (type(reference_source_info[0].default_output_coder())\n        != type(source_info[0].default_output_coder())):\n      raise ValueError(","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/io/source_test_utils.py#L125-L161","documentation":"In Beam's source_test_utils, assert_sources_equal_reference_source requires reference_source_info to be a three-element tuple whose first element is an iobase.BoundedSource (source, options, desired bundle size). It raises ValueError otherwise because the reference source is unpacked via read_from_source(*reference_source_info).","triggerScenarios":"Calling assert_sources_equal_reference_source with a two-element tuple, a list instead of a tuple, or a first element that is a custom Source rather than a BoundedSource subclass.","commonSituations":"Writing new BoundedSource unit tests and passing (source, options) forgetting the bundle-size hint, or migrating tests from the old Source API to BoundedSource.","solutions":["Pass a 3-tuple: (bounded_source, read_options, desired_bundle_size)","Ensure the first element is an instance of iobase.BoundedSource, not the legacy Source class","Wrap the source in a list of tuples form consistent with sources_info","Check tuple vs list — must be an actual tuple"],"exampleFix":"// before\nassert_sources_equal_reference_source((source, pipeline_options), ...)\n// after\nassert_sources_equal_reference_source((source, pipeline_options, 1000), ...)","handlingStrategy":"type-guard","validationCode":"from apache_beam.io import iobase\nassert isinstance(ref, tuple) and len(ref) == 3 and isinstance(ref[0], iobase.BoundedSource)","typeGuard":"def is_valid_source_info(info):\n    return isinstance(info, tuple) and len(info) == 3 and isinstance(info[0], iobase.BoundedSource)","tryCatchPattern":"try:\n    source_test_utils.assert_sources_equal_reference_source(ref, sources)\nexcept ValueError as e:\n    logger.error('Bad source test input: %s', e)","preventionTips":["Build source tuples via a helper that always includes desired_bundle_size","Migrate legacy Source objects to BoundedSource before testing","Add asserts in test fixtures for the 3-tuple shape"],"tags":["apache-beam","python","testing"],"backgroundTag":"invalid-argument-format","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"}