apache/beam · error · NotImplementedError

RangeTracker for not implemented!

Error message

RangeTracker for {type(start_position)} not implemented!

What it means

_MongoSource.get_range_tracker only supports int positions (OffsetRangeTracker) or str positions (LexicographicKeyRangeTracker). Any other start_position type reaches a NotImplementedError stating that no RangeTracker exists for that type. It is an internal API surfaced when the source is used with unexpected position objects.

Solutions

  1. Pass start/stop positions as int (for offset-based reads) or str (for lexicographic _id reads).
  2. Convert ObjectId positions to str via str(object_id) before requesting a range.
  3. If float, cast to int; if None, leave positions unset so defaults are used.
  4. If you truly need another position type, implement a custom RangeTracker and source instead of modifying mongodbio.

Example fix

// before
source.get_range_tracker(object_id, None)
// after
source.get_range_tracker(str(object_id), None)
Defensive patterns

Strategy: validation

Validate before calling

assert start_position is None or isinstance(start_position, (int, str)), 'unsupported position type'

Type guard

def supported_position(v) -> bool:
    return v is None or isinstance(v, (int, str)) and not isinstance(v, bool)

Try / catch

try:
    rt = source.get_range_tracker(start, stop)
except NotImplementedError:
    rt = source.get_range_tracker(str(start), str(stop))

Prevention

When it happens

Trigger: Custom splitters/DoFns or other code calling get_range_tracker with a position that is neither int nor str (e.g. ObjectId, float, tuple) — typically from custom partitioning logic or a modified MongoDBIO read path.

Common situations: Porting code that used ObjectId-based positions in an older/custom mongodbio variant; passing floats from JSON-deserialized offsets; writing a custom range splitter that hands non-int positions.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at sdks/python/apache_beam/io/mongodbio.py:385

                      position of the source must be used.
    Returns:
      a ``_ObjectIdRangeTracker``, ``OffsetRangeTracker``
      or ``LexicographicKeyRangeTracker`` depending on the given position range.
    """
    start_position, stop_position = self._replace_none_positions(
      start_position, stop_position
    )

    if isinstance(start_position, ObjectId):
      return _ObjectIdRangeTracker(start_position, stop_position)

    if isinstance(start_position, int):
      return OffsetRangeTracker(start_position, stop_position)

    if isinstance(start_position, str):
      return LexicographicKeyRangeTracker(start_position, stop_position)

    raise NotImplementedError(
        f"RangeTracker for {type(start_position)} not implemented!")

  def read(self, range_tracker):
    """Returns an iterator that reads data from the source.

    The returned set of data must respect the boundaries defined by the given
    ``RangeTracker`` object. For example:

      * Returned set of data must be for the range
        ``[range_tracker.start_position, range_tracker.stop_position)``. Note
        that a source may decide to return records that start after
        ``range_tracker.stop_position``. See documentation in class
        ``RangeTracker`` for more details. Also, note that framework might
        invoke ``range_tracker.try_split()`` to perform dynamic split
        operations. range_tracker.stop_position may be updated
        dynamically due to successful dynamic split operations.
      * Method ``range_tracker.try_split()`` must be invoked for every record
        that starts at a split point.

View on GitHub (pinned to 12126d8942)