{"record":{"id":"b5d6122927dd842f","repo":"apache/beam","slug":"source-r-is-empty","errorCode":null,"errorMessage":"Source %r is empty.","messagePattern":"Source %r is empty\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/io/source_test_utils.py","lineNumber":588,"sourceCode":"\n  Asserts that for each possible start position, a source can be split at\n  every interesting fraction (halfway between two fractions that differ by at\n  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:","sourceCodeStart":570,"sourceCodeEnd":606,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/io/source_test_utils.py#L570-L606","documentation":"assert_split_at_fraction_exhaustive first reads the source fully; if it yields no items the exhaustive split-fraction test cannot proceed, so it raises this ValueError. Splitting tests are meaningless over an empty source.","triggerScenarios":"Calling assert_split_at_fraction_exhaustive(source, start_position, stop_position) where read_from_source(source, start, stop) returns an empty list — e.g. the range [start, stop) contains no records or the underlying data is empty.","commonSituations":"Test fixture data file empty or not loaded; start_position >= stop_position passed explicitly; source configured with a filter/range that excludes all items; pointing the source at the wrong path in CI.","solutions":["Verify the source yields data by calling read_from_source(source) and checking it's non-empty before the exhaustive test.","Fix the start_position/stop_position arguments so the range covers at least one record (start < stop).","Check the underlying test data/fixture path is correct and non-empty.","Skip or guard the exhaustive test when the source is legitimately empty."],"exampleFix":"// before\nassert_split_at_fraction_exhaustive(source, 5, 5)  # empty range\n// after\nitems = read_from_source(source, 0, 10)\nassert items\nassert_split_at_fraction_exhaustive(source, 0, 10)","handlingStrategy":"validation","validationCode":"items = read_from_source(source, start_position, stop_position)\nif not items:\n    pytest.skip('source range is empty; skipping exhaustive split test')","typeGuard":null,"tryCatchPattern":"try:\n    assert_split_at_fraction_exhaustive(source, start, stop)\nexcept ValueError as e:\n    if 'is empty' in str(e):\n        pytest.skip(f'source produced no items: {e}')","preventionTips":["Verify fixtures exist and are non-empty before split tests","Assert start_position < stop_position in test setup","Check CI paths/working directories for data files"],"tags":["python","apache-beam","empty-source","test-harness"],"backgroundTag":"empty-result-set","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"}