Repository navigation
Reject duplicate object keys in NDJSON exports - #170
Open
DariusJDebugs wants to merge 2 commits into
Open
DariusJDebugs wants to merge 2 commits into
DariusJDebugs wants to merge 2 commits into
Conversation
|
Approve. A repeated key, including one inside a nested object, now rejects the whole page with |
This branch has not been deployed
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.
A row can declare dataset_version twice, first as 2 and then as 1. With a version 1 header the old decoder accepts the row because Python silently keeps the final value. The same behavior can discard nested review fields.
The decoder now inspects decoded key/value pairs for each object. If a dictionary has fewer entries than the pair list, a name appeared twice. Checking at this point catches equivalent JSON escapes and keeps the comparison local to each object. The SDK returns its existing invalid-response error without echoing field values. Earlier pages remain available, but the ambiguous page never reaches the caller.
This intentionally changes behavior for producers sending duplicate names. The hook adds temporary pair storage per object. CSV handling and public signatures are unchanged.
Verification
In the SDK development environment run
With the new tests and original decoder, five cases fail and the valid control passes. All six pass with the fix. Both sync and async tests use a local HTTP server to exercise pagination. All 242 tests passed, along with type checks, generation checks and installed package smoke tests. A separate local check rejected 500 repeated-name cases and preserved 500 distinct-name controls.
Review and performance
Proofline’s first code review on the fork reported no findings. The incremental review of the optimized decoder also reported no findings. Both reviews covered code only, so I checked runtime behavior separately. I kept the object-level check because the negative cases fail on the original decoder and the valid control preserves both rows. I changed how often the decoder is constructed after timing the first implementation.
On one local synthetic page of 1,000 rows, the original permissive parser took 2.11 ms, constructing a strict decoder per row took 4.44 ms, and reusing a strict decoder per page took 2.76 ms. Duplicate detection still has a cost. These are local measurements, excluding network time.
To reproduce, run this in each checkout with the SDK dependencies installed. The intermediate version is c22ce1c.
AI assistance was used to develop, test, and document this change.