Skip to content

fix(panel): decode NDJSON bulk bodies without throwing#16

Merged
Spamercz merged 2 commits into
v2.0from
fix/panel-logger-ndjson-bulk
Jul 17, 2026
Merged

fix(panel): decode NDJSON bulk bodies without throwing#16
Spamercz merged 2 commits into
v2.0from
fix/panel-logger-ndjson-bulk

Conversation

@Spamercz

Copy link
Copy Markdown
Contributor

Problem

With the Tracy debug panel enabled (debug: true), every _bulk request crashes with Nette\Utils\JsonException: Syntax error #4 before it is even sent. Elastic\Transport\Transport::sendRequest() logs the request through the PSR-3 logger, and PanelLogger::logQuery() runs Nette\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-items in api.colectio.com dev environments, which bulk-indexes through the client.

Fix

logQuery() now decodes bodies via a decodeBody() 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 PanelLoggerTest covers single-document JSON, NDJSON bulk bodies, undecodable bodies, and request/response pairing.

🤖 Generated with Claude Code

Spamercz and others added 2 commits July 17, 2026 15:08
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>
@Spamercz
Spamercz merged commit c6984f4 into v2.0 Jul 17, 2026
1 of 6 checks passed
@Spamercz
Spamercz deleted the fix/panel-logger-ndjson-bulk branch July 17, 2026 13:31
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.

1 participant