Fix flaky username generation in GetUserNameFromEmailAsync#25558
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a flaky username generation path in IdentityUserManager.GetUserNameFromEmailAsync when AllowedUserNameCharacters contains only a subset of digits, by generating the 4-digit suffix using only digits from the allowed set (per-digit selection) rather than using an integer range that can introduce disallowed digits.
Changes:
- Update
GetUserNameFromEmailAsyncto append 4 random digits by sampling from the distinct allowed digits set. - Tighten an existing test regex to require 4 allowed digits at the end (instead of 3).
- Add targeted regression tests covering partial digit sets, exact digit sets, and allowing leading zeroes in the random suffix.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs | Switches random digit suffix generation to sample only from allowed digits, eliminating disallowed-digit flakiness. |
| modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityUserManager_Tests.cs | Strengthens and expands test coverage to ensure generated usernames respect restricted digit sets and can include leading zeroes. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## rel-10.4 #25558 +/- ##
============================================
- Coverage 49.41% 49.38% -0.03%
============================================
Files 3674 3671 -3
Lines 124021 123880 -141
Branches 9477 9470 -7
============================================
- Hits 61280 61179 -101
+ Misses 60919 60867 -52
- Partials 1822 1834 +12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
salihozkara
approved these changes
Jun 5, 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.
Fix flaky CI failure in
IdentityUserManager.GetUserNameFromEmailAsyncwhenAllowedUserNameCharacterscontains a limited digit set: pick each random digit from the allowed set instead of generating an integer that may contain disallowed digits.