Skip to content

Conversation

asajjad2
Copy link
Contributor

What are the relevant tickets?

#8527

Description (What does it do?)

When OpenEdX returns empty username suggestions for usernames containing non-ASCII characters (like "Nguyễn"), the system was raising an OpenEdxUserCreateError instead of falling back to local username generation. This fix implements a fallback mechanism that generates unique usernames locally using random number suffixes when OpenEdX suggestions are unavailable.

Changes

  • Added _generate_unique_username() helper function to modularize username generation logic
  • Updated _create_edx_user_request() to fall back to local username generation when OpenEdX returns empty suggestions
  • Refactored reconcile_edx_username() to use the same modular username generation function

How can this be tested?

  1. Create a user with non-ASCII username: Nguyễn. Verify the user gets created both in MITxOnline and edX.
  2. Try to create another user with the same username
  3. Verify the behavior:
    • The second user should be created successfully (not fail with an error)
    • The second user should get a unique username with a random suffix
    • No OpenEdxUserCreateError should be raised
    • Both users should exist in the system with different usernames

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant