fix(panel): decode NDJSON bulk bodies without throwing#16
Merged
Conversation
Bulk API requests use NDJSON, which Nette Json::decode rejects as a syntax error. With the debug panel enabled this exception was thrown from the transport's PSR-3 logging before the request was sent, so every bulk call crashed. Decode NDJSON line by line and fall back to the raw string so diagnostics can never break the request itself. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Cover single-document JSON, NDJSON bulk bodies, undecodable bodies and request/response pairing so the panel logger's decoding behaviour is locked in. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
With the Tracy debug panel enabled (
debug: true), every_bulkrequest crashes withNette\Utils\JsonException: Syntax error #4before it is even sent.Elastic\Transport\Transport::sendRequest()logs the request through the PSR-3 logger, andPanelLogger::logQuery()runsNette\Utils\Json::decode()on the request body — but bulk bodies are NDJSON (one JSON document per line), not a single JSON document.This broke
elasticsearch:export-collection-itemsin api.colectio.com dev environments, which bulk-indexes through the client.Fix
logQuery()now decodes bodies via adecodeBody()helper: single JSON document first, NDJSON line-by-line as fallback, and the raw string if neither parses — so the diagnostics logger can never break the request itself. Applied to both the request and response paths.Tests
New
PanelLoggerTestcovers single-document JSON, NDJSON bulk bodies, undecodable bodies, and request/response pairing.🤖 Generated with Claude Code