Skip to content

Improve Error Handling and API Usability for Stream Operations #691

Description

@krasnovdm

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

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions