Skip to content

fix(output): throw server error for streamed exceptions#336

Merged
simPod merged 3 commits into
masterfrom
fix/json-each-row-streamed-exceptions
Jul 11, 2026
Merged

fix(output): throw server error for streamed exceptions#336
simPod merged 3 commits into
masterfrom
fix/json-each-row-streamed-exceptions

Conversation

@simPod

@simPod simPod commented Jul 10, 2026

Copy link
Copy Markdown
Owner

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

  • Streaming JSONEachRow consumers preserve ClickHouse server-error semantics.
  • Both string and stream-backed JSONEachRow outputs handle streamed exception frames consistently.

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.99%. Comparing base (725353b) to head (e65943c).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 iterating Output\JsonEachRow lines and throw ServerError::fromResponseContent(...) instead of surfacing a JsonException.
  • Add test coverage ensuring both string-backed and stream-backed JSONEachRow contents throw ServerError on streamed exception frames.
  • Update Format\JsonEachRow PHPDoc 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.

Comment thread src/Output/JsonEachRow.php

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@simPod simPod merged commit 6c28d2c into master Jul 11, 2026
20 checks passed
@simPod simPod deleted the fix/json-each-row-streamed-exceptions branch July 11, 2026 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants