fix(output): throw server error for streamed exceptions#336
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #336 +/- ##
==========================================
+ Coverage 95.94% 95.99% +0.04%
==========================================
Files 42 42
Lines 839 849 +10
==========================================
+ Hits 805 815 +10
Misses 34 34 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR updates the JSONEachRow output decoder to detect ClickHouse streamed exception frames (__exception__ ...) during line-by-line decoding and rethrow them as ServerError, preserving client-level server error semantics for streaming consumers.
Changes:
- Detect
__exception__frames while iteratingOutput\JsonEachRowlines and throwServerError::fromResponseContent(...)instead of surfacing aJsonException. - Add test coverage ensuring both string-backed and stream-backed
JSONEachRowcontents throwServerErroron streamed exception frames. - Update
Format\JsonEachRowPHPDoc to reflect the additional thrown exception type.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/Output/JsonEachRowTest.php | Adds a data-provider test verifying streamed exception frames throw ServerError for both strings and streams. |
| src/Output/JsonEachRow.php | Implements streamed exception frame detection during JSONEachRow decoding and rethrows as ServerError. |
| src/Format/JsonEachRow.php | Updates @throws annotations to include ServerError. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
ClickHouse can emit streamed exception frames after response headers. JsonEachRow currently attempts to decode those frames as JSON, surfacing a JsonException instead of the client-level ServerError.
Decision
Detect exception frames while consuming JSONEachRow lines and rethrow them through ServerError::fromResponseContent().
Consequences