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

HTTPError: 502 Server Error triggered by repair_faulty_edx_user, non-ascii username #2574

Open
sentry-io bot opened this issue Feb 14, 2023 · 4 comments
Labels
Bug Something isn't working

Comments

@sentry-io
Copy link

sentry-io bot commented Feb 14, 2023

Sentry Issue: XPRO-5ZG

HTTPError: 502 Server Error: Bad Gateway for url: https://courses.xpro.mit.edu/auth/complete/mitxpro-oauth2/?redirect_state=5O8jLzykCZksmXK8Zc63qbgU69yc40sO&code=PVvo0FieLNiF19hQlWusWrh50P9miV&state=5O8jLzykCZksmXK8Zc63qbgU69yc40sO
  File "courseware/api.py", line 317, in repair_faulty_courseware_users
    created_user, created_auth_token = repair_faulty_edx_user(user)
  File "courseware/api.py", line 297, in repair_faulty_edx_user
    created_auth_token = create_edx_auth_token(user) is not None
  File "contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "courseware/api.py", line 163, in create_edx_auth_token
    resp.raise_for_status()
  File "requests/models.py", line 960, in raise_for_status
    raise HTTPError(http_error_msg, response=self)

Failed to repair faulty user Response - code: 502, url: https://courses.xpro.mit.edu/auth/complete/mitxpro-oauth2/?redirect_state=... content: (HTML body ignored)
@mbertrand
Copy link
Member

mbertrand commented Feb 14, 2023

Response content from edx server is HTML with text:

Uh oh, we are having some server issues..
Server error
We are aware of the error and are working to find a resolution.

from courseware.api.create_edx_auth_token:

        url = edx_url(OPENEDX_SOCIAL_LOGIN_XPRO_PATH)
        resp = req_session.get(url)
        resp.raise_for_status()

@mbertrand
Copy link
Member

mbertrand commented Feb 14, 2023

Appears to be related to non-ascii "full name".

To recreate:

  • Register as a new user. When filling out the "Full Name" field, use the same value as in the linked sentry error. Use regular ascii characters for first and last name fields.
  • Purchase a course/program
  • Click the edx link to the course. Instead of loading, it shows a server error page.

@mbertrand
Copy link
Member

mbertrand commented Feb 14, 2023

When creating the user in local xpro with devstack:

web_1     | [2023-02-14 15:44:32] ERROR 15 [root] user.py:282 - [c15bbfb46fcc] - Error creating courseware user records on User create
web_1     | Traceback (most recent call last):
web_1     |   File "/src/./authentication/pipeline/user.py", line 280, in create_courseware_user
web_1     |     courseware_api.create_user(user)
web_1     |   File "/src/./courseware/api.py", line 70, in create_user
web_1     |     create_edx_user(user)
web_1     |   File "/src/./courseware/api.py", line 114, in create_edx_user
web_1     |     raise CoursewareUserCreateError(
web_1     | courseware.exceptions.CoursewareUserCreateError: Error creating Open edX user. Response - code: 400, content: {
web_1     |   "username": [
web_1     |     {
web_1     |       "user_message": "Usernames can only contain letters (A-Z, a-z), numerals (0-9), underscores (_), and hyphens (-)."
web_1     |     }
web_1     |   ],
web_1     |   "error_code": "validation-error"
web_1     | }

False alarm, does not happen on RC or prod. Must be a local devstack setting somewhere.

@mbertrand mbertrand changed the title HTTPError: 502 Server Error triggered by repair_faulty_edx_user HTTPError: 502 Server Error triggered by repair_faulty_edx_user, non-ascii username Feb 14, 2023
@mbertrand mbertrand added the Bug Something isn't working label Feb 14, 2023
@mbertrand
Copy link
Member

Error occurs with usernames having non-ascii characters, but there does not seem to be a standard length beyond which the error is raised.

A sample name in Chinese characters only works when the number of unicode characters is shortened to a length of 10:
奕泽-奕泽-奕泽-奕

Adding one more Chinese character causes the error.

But a sample name in Arabic characters works when the number of unicode characters is twice that length.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant