Repository navigation
Fix global clearing of exclusion-only unique generators - #3334
Open
sergioperezcheco wants to merge 1 commit into
Open
sergioperezcheco wants to merge 1 commit into
sergioperezcheco wants to merge 1 commit into
Conversation
Register wrappers when exclude populates their thread-local results, so global clear also visits generators that have not generated a value since its last call. Cover both lifecycle cases and thread isolation. Assisted-by: OpenAI Signed-off-by: sergioperezcheco <checo520@outlook.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.
Motivation / Background
Faker::UniqueGenerator.cleardoes not clear exclusions for a generator that has not generated a value since the last global clear. For example, excluding the only available value, calling global clear, and then generating it still raisesRetryLimitExceeded.Global clear walks the thread-local
marked_uniqueset. Generation registers its wrapper in that set, butexcludeonly updates the results cache. Register the wrapper when exclusions are added too, using the same existing registration path. This also fixes exclusion-only use after a previous global clear without changing thread isolation or exclusion semantics.Additional information
Added regression tests for exclusions before first generation, exclusions after a previous global clear, and clearing from another thread. Independently checked both lifecycle cases through
Faker::Base.unique; the original implementation raises and the fix returns the excluded value after clearing.On Ruby 3.4.11/macOS, the focused tests, full
bundle exec raketest and RuboCop run, andFAKER_LAZY_LOAD=1 bundle exec rake testpass. Built and installed the gem into an isolated directory and checked the public API there too. The other Ruby/OS CI combinations have not been run locally.AI assistance was used for investigation, implementation, and tests; the changes were independently reviewed and exercised by the coordinating agent.
Checklist