Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenEdXOAuth2Error: Redirected to 'https://courses.mitxonline.mit.edu/register', expected: 'https://mitxonline.mit.ed... #1493

Open
sentry-io bot opened this issue Mar 16, 2023 · 6 comments · Fixed by #1496
Assignees

Comments

@sentry-io
Copy link

sentry-io bot commented Mar 16, 2023

Sentry Issue: MITXONLINE-2JA

OpenEdXOAuth2Error: Redirected to 'https://courses.mitxonline.mit.edu/register', expected: 'https://mitxonline.mit.edu/login/_private/complete'
  File "openedx/api.py", line 344, in repair_faulty_openedx_users
    created_user, created_auth_token = repair_faulty_edx_user(user)
  File "openedx/api.py", line 311, in repair_faulty_edx_user
    create_edx_auth_token(user)
  File "contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "openedx/api.py", line 191, in create_edx_auth_token
    raise OpenEdXOAuth2Error(

Failed to repair faulty user REDACTED (REDACTED)
@collinpreston
Copy link
Contributor

So this is still occurring, but since the release of the most recent PR associated with this issue, occurrences have dropped quite a bit:
Screenshot 2023-03-21 at 8 06 23

It appears that the remaining occurrences are related to username conflicts on edx. This is handled here:

mitxonline/openedx/api.py

Lines 309 to 316 in fe1146f

if "code: 409" in str(e):
pass
else:
raise Exception from e
if not hasattr(user, "openedx_api_auth"):
create_edx_auth_token(user)

@pdpinch
Copy link
Member

pdpinch commented Jun 2, 2023

What's next for this? Do we clean up the data, or add more error handling code?

@pdpinch
Copy link
Member

pdpinch commented Jul 21, 2023

@collinpreston what do you think we should do with this? I think we're down to just 2 users, but they keep throwing errors on a regular basis.

@collinpreston
Copy link
Contributor

@pdpinch
So the following is true for two reoccurring users with this problem:

  1. Accounts exist in MITx Online and edX with the same username.
  2. The accounts in MITx Online and edX with the same username, have different email addresses.
  3. No MITx Online accounts the email address from either edX account with a matching username.
  4. The accounts in MITx Online and edX with the same username, have create timestamps that differ by many months.
  5. All accounts were created prior to the edX username validation being implemented in the registration process.

I could use some help thinking how this might have happened.

@arslanashraf7
Copy link
Contributor

@collinpreston I think there might be a couple of reasons for this:

  1. I'm not sure if we soft-fail the registration for users if we face 409 conflict errors while registering. If we are soft fail and register the user in MITxOnline and try the user repair later. So the user exists in MITxOnline and doesn't get created in the edX instance.
  2. There is also a chance that there might be issues with case sensitivity here, For example, check this user https://courses.mitxonline.mit.edu/admin/auth/user/7970/change/?_changelist_filters=q%3DArushi in edX and https://mitxonline.mit.edu/admin/users/user/38557/change/?_changelist_filters=q%3Darushi in MITxOnline. They both have the same username except that one has A and the other has a. And both of these look like the same user but have different emails.

@collinpreston
Copy link
Contributor

@arslanashraf7, so when user's register through MITx Online, the registration screen will perform a validation to ensure the username entered into the registration form is unique in MITx Online and edX. If the validation with edX fails for any reason, we will not proceed with registering the user.

I figured case sensitivity as well and tested that in RC. The username validation appears to be case-insensitive.

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 a pull request may close this issue.

3 participants