{"record":{"id":"bd72c33479ef09de","repo":"apache/beam","slug":"unknown-type-of-expected-outcome-r","errorCode":null,"errorMessage":"Unknown type of expected outcome: %r","messagePattern":"Unknown type of expected outcome: %r","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/io/source_test_utils.py","lineNumber":346,"sourceCode":"      raise ValueError(\n          'Expected split of source %r at fraction %r to be '\n          'successful after reading %d elements. But '\n          'the split failed.' %\n          (source, split_fraction, num_items_to_read_before_split))\n  elif expected_outcome == ExpectedSplitOutcome.MUST_FAIL:\n    if split_result:\n      raise ValueError(\n          'Expected split of source %r at fraction %r after '\n          'reading %d elements to fail. But splitting '\n          'succeeded with result %r.' % (\n              source,\n              split_fraction,\n              num_items_to_read_before_split,\n              split_result))\n\n  elif (expected_outcome\n        != ExpectedSplitOutcome.MUST_BE_CONSISTENT_IF_SUCCEEDS):\n    raise ValueError('Unknown type of expected outcome: %r' % expected_outcome)\n  current_items.extend([value for value in reader_iter])\n\n  residual_range = (\n      split_result[0], stop_position_before_split) if split_result else None\n\n  return _verify_single_split_fraction_result(\n      source,\n      expected_items,\n      current_items,\n      split_result,\n      (range_tracker.start_position(), range_tracker.stop_position()),\n      residual_range,\n      split_fraction)\n\n\ndef _range_to_str(start, stop):\n  return '[' + (str(start) + ',' + str(stop) + ')')\n","sourceCodeStart":328,"sourceCodeEnd":364,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/io/source_test_utils.py#L328-L364","documentation":"Raised by _assert_split_at_fraction_behavior when the expected_outcome argument is not one of the ExpectedSplitOutcome enum values (MUST_FAIL, MUST_BE_CONSISTENT_IF_SUCCEEDS). It is a guard against passing an unknown or mis-spelled outcome specifier.","triggerScenarios":"Passing a raw string like 'MUST_SUCCEED', None, a boolean, or an invalid enum member to assert_split_at_fraction_behavior / assert_split_at_fraction_binary as expected_outcome.","commonSituations":"Typo in the ExpectedSplitOutcome member name; constructing the enum value from config or a variable that holds the wrong type; older code written against a different enum variant set.","solutions":["Use a valid member: ExpectedSplitOutcome.MUST_FAIL, ExpectedSplitOutcome.MUST_BE_CONSISTENT_IF_SUCCEEDS (or MUST_SUCCEED where supported).","Print ExpectedSplitOutcome.__members__ to see the allowed values before passing one.","If the outcome comes from external config, validate it against the enum before calling the assertion.","Check imports — comparing against a similarly named constant from another module yields an unknown value."],"exampleFix":"// before\nassert_split_at_fraction_binary(source, 'MUST_SUCCEED', fraction=0.5)\n// after\nfrom apache_beam.io.iobase import ExpectedSplitOutcome\nassert_split_at_fraction_binary(source, ExpectedSplitOutcome.MUST_SUCCEED, fraction=0.5)","handlingStrategy":"type-guard","validationCode":"from apache_beam.io.iobase import ExpectedSplitOutcome\nif not isinstance(expected_outcome, ExpectedSplitOutcome):\n    raise TypeError(f'expected_outcome must be an ExpectedSplitOutcome, got {expected_outcome!r}')","typeGuard":"def is_expected_split_outcome(v):\n    return isinstance(v, ExpectedSplitOutcome)","tryCatchPattern":"try:\n    assert_split_at_fraction_binary(source, outcome)\nexcept ValueError as e:\n    if 'Unknown type of expected outcome' in str(e):\n        logging.error('Bad expected_outcome: %r', outcome)","preventionTips":["Always import ExpectedSplitOutcome and use its members directly","Never pass raw strings or booleans as expected_outcome","Validate config-driven outcomes against ExpectedSplitOutcome.__members__"],"tags":["python","apache-beam","invalid-argument","enum","source-testing"],"backgroundTag":"invalid-enum-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}