Repository navigation
Conversation
build_shallow_hash assigned `width` times into a hash, so a repeated key (two equal first names) silently produced fewer than `width` entries in shallow_json and every level of add_depth_to_json. Retry on duplicates, bounded so a key generator with fewer than `width` values can't loop. This is what makes test_nested_json_length fail when the random stream lands on a duplicate name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 tasks done
dpep
commented
Oct 4, 2026
dpep
commented
Oct 4, 2026
dpep
commented
Oct 4, 2026
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.
Motivation / Background
This Pull Request has been created because
Faker::Json.shallow_jsonandadd_depth_to_jsonreturn fewer thanwidthkeys when two generated keys collide.build_shallow_hashassigns into a hashwidthtimes, so a repeated first name overwrites an entry. This is also whytest_nested_json_lengthfails whenever the random sequence draws a duplicate name.It now retries on duplicates. The retries are bounded (10 ×
widthattempts), so a key generator with fewer thanwidthdistinct values (e.g.Boolean.booleanwithwidth: 3) still returns.Additional information
The new
test_shallow_json_keeps_width_when_keys_collidepins a seed where the first two boolean keys are equal. It fails without the fix ("<2> expected but was <1>") and passes with it.rake testand rubocop pass.Checklist
[Fix #issue-number]Found via trekr, while turning back on a test it flagged as never running.