Skip to content

bug: Exception raises when trying to set read_from in TopicReaderSelector #695

@weres-sa

Description

@weres-sa

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions