ydb-platform / ydb-platform/ydb-python-sdk

Improve Error Handling and API Usability for Stream Operations

Open
#691 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
102
Forks
75
Avg merge
1d 23h
Merged PRs (30d)
13

Description

Feature Request

Describe the Feature Request

The current implementation of stream operations in the YDB Python SDK (specifically for session.transaction().execute()) allows users to execute queries without properly consuming the response stream. This can lead to silent failures where:

  • Queries (especially UPSERT operations) appear to execute successfully (no exceptions raised)
  • Data is not actually persisted in the database
  • No warnings or errors are logged to indicate incomplete operation
  • The root cause is difficult to diagnose (users must be aware of internal stream mechanics)

Describe Preferred Solution

Implement runtime warnings when:

  • A stream is not fully consumed and may have errors.

Describe Alternatives

Improve documentation to emphasize stream consumption requirements

Related Code

with ydb.QuerySessionPool(driver) as pool:
with pool.checkout() as session:
    session.transaction(tx_mode=ydb.QuerySerializableReadWrite()).execute(
        query=query_to_upsert,
        parameters={
            "$data": ydb.TypedValue(data_to_upsert, ydb.ListType(TestSerialStruct))
        },
        commit_tx=True,
    )

Additional Context
The API should prevent "successful no-ops" through:

If the feature request is approved, would you be willing to submit a PR?
No

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Python SDK's session.transaction().execute() entry point and trace how its response stream is consumed. Determine how incomplete consumption is detected and what runtime warning behavior is appropriate. Done means incomplete streams that may contain errors are surfaced instead of silently producing successful no-ops; the issue also suggests documenting the consumption requirement.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.