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

bug: Topic API TypeError: exceptions must derive from BaseException

Open kbespalov opened this issue 1 year ago • 1 comments

Bug Report

YDB GO Python version:

ydb==3.2.2

Current behavior:

    result = future.result(timeout=self._endpoint_config.start_wait_timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/_base.py", line 445, in result
    return self.__get_result()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/_base.py", line 390, in __get_result
    raise self._exception
  File "/Users/kbespalov/workspace/billing_venv/lib/python3.9/site-packages/ydb/_topic_writer/topic_writer_asyncio.py", line 158, in wait_init
    return await self._reconnector.wait_init()
  File "/Users/kbespalov/workspace/billing_venv/lib/python3.9/site-packages/ydb/_topic_writer/topic_writer_asyncio.py", line 259, in wait_init
    raise self._stop_reason.exception()
TypeError: exceptions must derive from BaseException

Expected behavior:

Check for None ?

Steps to reproduce:

Try to create producer for non-existent topic

  File "/Users/kbespalov/workspace/billing_venv/lib/python3.9/site-packages/ydb/_topic_writer/topic_writer_asyncio.py", line 636, in _start
    resp = await stream.receive()
  File "/Users/kbespalov/workspace/billing_venv/lib/python3.9/site-packages/ydb/_grpc/grpcwrapper/common_utils.py", line 199, in receive
    issues._process_response(grpc_message)
  File "/Users/kbespalov/workspace/billing_venv/lib/python3.9/site-packages/ydb/issues.py", line 197, in _process_response
    raise exc_obj(_format_response(response_proto), response_proto.issues)
ydb.issues.SchemeError: message: "no path \'local/topic\', Marker# PQ15" issue_code: 500017 severity: 1 (server_code: 400070)

Method

    async def wait_init(self) -> PublicWriterInitInfo:
        while True:
            if self._stop_reason.done():
                raise self._stop_reason.exception()

            if self._init_info:
                return self._init_info

            await self._state_changed.wait()

kbespalov avatar Apr 27 '23 10:04 kbespalov

This exception appears when trying to write to a non-existent topic.

To reproduce the issue run following snippets separately one after another (different exception is raised when running individual parts as a single script):

import ydb
db = ydb.Driver(
    connection_string="grpc://localhost:2135?database=/local",
    credentials=ydb.credentials.AnonymousCredentials(),
)
writer = db.topic_client.writer(
        "/local/topic",  # <------------------------ non-existent topic
        producer_id="producer-id",
    )
ii = writer.wait_init(timeout=10)

Expected result:

Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevconsole.py", line 364, in runcode
    coro = func()
  File "<input>", line 1, in <module>
  File "/Users/pltnkv/code/ydb-python-sdk/ydb/_topic_writer/topic_writer_sync.py", line 94, in wait_init
    return self._caller.unsafe_call_with_result(self._async_writer.wait_init(), timeout)
  File "/Users/pltnkv/code/ydb-python-sdk/ydb/_topic_common/common.py", line 83, in unsafe_call_with_result
    return f.result(timeout)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/concurrent/futures/_base.py", line 445, in result
    return self.__get_result()
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/concurrent/futures/_base.py", line 390, in __get_result
    raise self._exception
  File "/Users/pltnkv/code/ydb-python-sdk/ydb/_topic_writer/topic_writer_asyncio.py", line 158, in wait_init
    return await self._reconnector.wait_init()
  File "/Users/pltnkv/code/ydb-python-sdk/ydb/_topic_writer/topic_writer_asyncio.py", line 259, in wait_init
    raise self._stop_reason.exception()
TypeError: exceptions must derive from BaseException

pltnk avatar Apr 27 '23 10:04 pltnk