ydb-python-sdk icon indicating copy to clipboard operation
ydb-python-sdk copied to clipboard

bug: Exception raises when trying to set read_from in TopicReaderSelector

Open weres-sa opened this issue 5 months ago • 0 comments

Bug Report

YDB Python SDK version:

3.21.7

Environment

MacOS 14.4, M1 Pro, Python 3.13.4

Current behavior:

Exception raised:

File /opt/homebrew/lib/python3.13/site-packages/ydb/_grpc/grpcwrapper/ydb_topic.py:491, in StreamReadMessage.InitRequest.TopicReadSettings.to_proto(self)
    489 read_from = proto_timestamp_from_datetime(self.read_from)
    490 if read_from is not None:
--> 491     res.read_from = read_from
    493 return res

AttributeError: Assignment not allowed to message, map, or repeated field "read_from" in protocol message object.

Expected behavior:

Message successfully read.

Steps to reproduce:

with ydb.Driver(driver_config) as driver:
    driver.wait()
    with driver.topic_client.reader(
        topic=ydb.TopicReaderSelector(
            path="my_topic",
            partitions=[2],
            read_from=datetime(2025, 8, 11, 5, 45, 0, tzinfo=UTC)
        ),
        consumer="my_consumer"
    ) as reader:
        msg = reader.receive_message()
        print(msg.written_at)

Related code:

insert short code snippets here

Other information:

Way to fix - change code here (https://github.com/ydb-platform/ydb-python-sdk/blob/3.21.7/ydb/_grpc/grpcwrapper/ydb_topic.py#L491)

                # read_from = proto_timestamp_from_datetime(self.read_from)
                if self.read_from is not None:
                    res.read_from.FromDatetime(self.read_from)

Probably there are another bug a fewlines upper with google.protobuf.Duration assignment as well.

weres-sa avatar Aug 13 '25 11:08 weres-sa