Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces robust stream termination validation for both synchronous and asynchronous streamed result sets, ensuring that sticky terminal errors are recorded and raised if a stream ends mid-chunk, mid-row, or with invalid metadata. It also adds comprehensive test coverage for these scenarios. The review feedback correctly points out that one_or_none() should check and raise self._error at the beginning of the method in both implementations to prevent silent failures when a stream has previously encountered a terminal error.
Previously, streaming query results silently ignored trailing partial data if a stream ended mid-row, while waiting for the next part of a chunked value, or with missing column metadata. This could cause callers to receive truncated results without any error. Note that the above problems should never happen as long as Spanner adheres to its own contract. This is therefore purely a hardening for potential data corruption. Now both the sync and async streaming result sets detect these malformed terminations and raise an internal server error across all consumption methods (iteration, single-row lookups, and dictionary conversion), keeping the failure sticky if the result set is read again. Includes symmetric sync/async unit tests and end-to-end mock server tests covering truncated chunks, incomplete rows, and missing row metadata.
704ad29 to
7f5e1e6
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces validation for stream termination in both the synchronous and asynchronous streamed result sets (streamed.py). It ensures that an InternalServerError is raised and sticky-cached if a stream ends unexpectedly (e.g., mid-chunk, mid-row, with missing metadata, or with empty chunked values). Comprehensive unit and mock server tests have been added to cover these invalid termination scenarios, and existing tests were updated accordingly. I have no feedback to provide as there are no review comments.
Previously, streaming query results silently ignored trailing partial data if a stream ended mid-row, while waiting for the next part of a chunked value, or with missing column metadata. This could cause callers to receive truncated results without any error.
Note that the above problems should never happen as long as Spanner adheres to its own contract. This is therefore purely a hardening for potential data corruption.
Now both the sync and async streaming result sets detect these malformed terminations and raise an internal server error across all consumption methods (iteration, single-row lookups, and dictionary conversion), keeping the failure sticky if the result set is read again.
Includes symmetric sync/async unit tests and end-to-end mock server tests covering truncated chunks, incomplete rows, and missing row metadata.