fix: keep closing brackets when desyncing after a complete JSON array - #305
Open
detail-app[bot] wants to merge 1 commit into
Open
detail-app[bot] wants to merge 1 commit into
detail-app[bot] wants to merge 1 commit into
Conversation
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a one-line JSON-array framing fix that restores deferred closing brackets before malformed trailing data is copied through, with regression coverage for chunk boundaries and empty/non-empty arrays. Existing valid-input behavior and unrelated paths are unchanged. You can add or adjust custom eligibility rules. Learn more. |
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.
Detail bug report: View on Detail
Fixes ENG-706
Bug
JsonArrayFramerdefers emitting the array brackets (especially the closing]) untilfinish()callswriteClose. When the.donestate (the closing]already consumed) hit trailing non-whitespace junk, it calledenterDesyncdirectly and switched to verbatim copy-through without ever writing the deferred brackets, andfinish()'s empty.desyncarm never recovered them. So[1]extrawas emitted as[1extraand[](as(. The.done→.desyncpath was uniquely missing bracket emission — the sibling.in_elementand.expect_element_or_enddesync paths both close the array viawriteCloseinfinish().Fix
Call
writeClose(out)beforeenterDesyncin the.donestate, mirroring those siblingfinish()branches.writeClosealready handles bothwrote_open == true(non-empty array: emits]) andwrote_open == false(empty array: emits[then]), so both sub-cases are covered. One line insrc/pipeline/frame_json_array.zig.Testing
frame_json_array.zig): drives[1]extraand[](throughrunChunkedacross chunk sizes{1, 7, 4096}(the.donestate carries acrossingestcalls, so chunk-boundary placement matters), asserting byte-preserving output of[1]extra/[](.zig build testis green (one pre-existing env-dependent S3 e2e test skipped);zig fmt --check,ziglint, and debug +ReleaseSafebuilds pass;task do(format + lint + ReleaseSafe test) andtask build:safeare green.edge-datadogdistribution against the repo'secho-serveras a capture upstream. POSTing[{"message":"hi"}],[1]extra, and[](to/api/v2/logs(the production.pipe_stream/.format = .json_arraypath), the upstream captured[{"message":"hi"}],[1]extra, and[](respectively — vs. the bug's[1extra/(— confirming the fix at the wire level with no regression on valid input.task test:s3-e2e(the S3-dump MinIO e2e) could not be run here — Docker failed to pullminio/minio(registry access denied). It exercises the unrelated S3-dump extension and is independent of this change; it is also the single pre-existing skip in the normal test suite.Automatic Fixes PRs can be configured here.