{"record":{"id":"f3234344074a3423","repo":"apache/beam","slug":"source-r-only-reads-a-single-item","errorCode":null,"errorMessage":"Source %r only reads a single item.","messagePattern":"Source %r only reads a single item\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/io/source_test_utils.py","lineNumber":591,"sourceCode":"  least one item) and the results are consistent if a split succeeds.\n  Verifies multi threaded splitting as well.\n\n  Args:\n    source (~apache_beam.io.iobase.BoundedSource): the source to perform\n      dynamic splitting on.\n    perform_multi_threaded_test (bool): if :data:`True` performs a\n      multi-threaded test, otherwise this test is skipped.\n\n  Raises:\n    ValueError: if the exhaustive splitting test fails.\n  \"\"\"\n\n  expected_items = read_from_source(source, start_position, stop_position)\n  if not expected_items:\n    raise ValueError('Source %r is empty.' % source)\n\n  if len(expected_items) == 1:\n    raise ValueError('Source %r only reads a single item.' % source)\n\n  all_non_trivial_fractions = []\n\n  any_successful_fractions = False\n  any_non_trivial_fractions = False\n\n  for i in range(len(expected_items)):\n    stats = SplitFractionStatistics([], [])\n\n    assert_split_at_fraction_binary(\n        source, expected_items, i, 0.0, None, 1.0, None, stats)\n\n    if stats.successful_fractions:\n      any_successful_fractions = True\n    if stats.non_trivial_fractions:\n      any_non_trivial_fractions = True\n\n    all_non_trivial_fractions.append(stats.non_trivial_fractions)","sourceCodeStart":573,"sourceCodeEnd":609,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/io/source_test_utils.py#L573-L609","documentation":"assert_split_at_fraction_exhaustive requires at least two items because a split is only non-trivial when both primary and residual are non-empty; a single-item source cannot produce a meaningful split, so the harness raises this ValueError.","triggerScenarios":"Calling assert_split_at_fraction_exhaustive on a source whose range [start_position, stop_position) contains exactly one item.","commonSituations":"Tiny hand-built test sources (e.g. ['a'] or range(1)); overly narrow start/stop positions trimming the data to one record; a filter in the source leaving a single element.","solutions":["Provide a source with at least two items over the tested range.","Widen start_position/stop_position so the range spans multiple records.","Use assert_split_at_fraction_binary on a single-item source only if you expect all splits to fail, rather than the exhaustive test.","Generate synthetic multi-item data in the test fixture."],"exampleFix":"// before\nassert_split_at_fraction_exhaustive(source_from_items(['only']), 0, 1)\n// after\nassert_split_at_fraction_exhaustive(source_from_items(['a', 'b', 'c']), 0, 3)","handlingStrategy":"validation","validationCode":"items = read_from_source(source, start_position, stop_position)\nif len(items) < 2:\n    pytest.skip('need >=2 items for exhaustive split test')","typeGuard":null,"tryCatchPattern":"try:\n    assert_split_at_fraction_exhaustive(source, start, stop)\nexcept ValueError as e:\n    if 'single item' in str(e):\n        pytest.skip(f'source too small: {e}')","preventionTips":["Build test sources with several items (e.g. range(10))","Widen start/stop ranges to cover multiple records","Prefer assert_split_at_fraction_binary for tiny sources"],"tags":["python","apache-beam","test-harness","split-at-fraction"],"backgroundTag":"invalid-argument-value","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"}