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

Fix: registering a new user with a full name longer than 255 characters #34577

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DmytroAlipov
Copy link
Contributor

@DmytroAlipov DmytroAlipov commented Apr 23, 2024

Description

Fixing an error when a new user tries registering on the platform with a name longer than 255 characters.

edx.quince-rg.lms  | The above exception was the direct cause of the following exception:
edx.quince-rg.lms  | 
edx.quince-rg.lms  | Traceback (most recent call last):
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/core/handlers/exception.py", line 55, in inner
edx.quince-rg.lms  |     response = get_response(request)
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/core/handlers/base.py", line 197, in _get_response
edx.quince-rg.lms  |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 56, in wrapper_view
edx.quince-rg.lms  |     return view_func(*args, **kwargs)
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/views/generic/base.py", line 104, in view
edx.quince-rg.lms  |     return self.dispatch(request, *args, **kwargs)
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/utils/decorators.py", line 46, in _wrapper
edx.quince-rg.lms  |     return bound_method(*args, **kwargs)
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/utils/decorators.py", line 46, in _wrapper
edx.quince-rg.lms  |     return bound_method(*args, **kwargs)
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/views/decorators/debug.py", line 92, in sensitive_post_parameters_wrapper
edx.quince-rg.lms  |     return view(request, *args, **kwargs)
edx.quince-rg.lms  |   File "/edx/app/edxapp/edx-platform/openedx/core/djangoapps/user_authn/views/register.py", line 531, in dispatch
edx.quince-rg.lms  |     return super().dispatch(request, *args, **kwargs)
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch
edx.quince-rg.lms  |     response = self.handle_exception(exc)
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/rest_framework/views.py", line 469, in handle_exception
edx.quince-rg.lms  |     self.raise_uncaught_exception(exc)
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
edx.quince-rg.lms  |     raise exc
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/rest_framework/views.py", line 506, in dispatch
edx.quince-rg.lms  |     response = handler(request, *args, **kwargs)
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/utils/decorators.py", line 46, in _wrapper
edx.quince-rg.lms  |     return bound_method(*args, **kwargs)
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 56, in wrapper_view
edx.quince-rg.lms  |     return view_func(*args, **kwargs)
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/utils/decorators.py", line 46, in _wrapper
edx.quince-rg.lms  |     return bound_method(*args, **kwargs)
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django_ratelimit/decorators.py", line 27, in _wrapped
edx.quince-rg.lms  |     return fn(request, *args, **kw)
edx.quince-rg.lms  |   File "/edx/app/edxapp/edx-platform/openedx/core/djangoapps/user_authn/views/register.py", line 587, in post
edx.quince-rg.lms  |     response, user = self._create_account(request, data)
edx.quince-rg.lms  |   File "/edx/app/edxapp/edx-platform/openedx/core/djangoapps/user_authn/views/register.py", line 666, in _create_account
edx.quince-rg.lms  |     user = create_account_with_params(request, data)
edx.quince-rg.lms  |   File "/edx/app/edxapp/edx-platform/openedx/core/djangoapps/user_authn/views/register.py", line 211, in create_account_with_params
edx.quince-rg.lms  |     (user, profile, registration) = do_create_account(form, custom_form)
edx.quince-rg.lms  |   File "/edx/app/edxapp/edx-platform/common/djangoapps/student/helpers.py", line 753, in do_create_account
edx.quince-rg.lms  |     profile.save()
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 814, in save
edx.quince-rg.lms  |     self.save_base(
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 877, in save_base
edx.quince-rg.lms  |     updated = self._save_table(
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 1020, in _save_table
edx.quince-rg.lms  |     results = self._do_insert(
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/base.py", line 1061, in _do_insert
edx.quince-rg.lms  |     return manager._insert(
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/manager.py", line 87, in manager_method
edx.quince-rg.lms  |     return getattr(self.get_queryset(), name)(*args, **kwargs)
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/query.py", line 1805, in _insert
edx.quince-rg.lms  |     return query.get_compiler(using=using).execute_sql(returning_fields)
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1822, in execute_sql
edx.quince-rg.lms  |     cursor.execute(sql, params)
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/debug_toolbar/panels/sql/tracking.py", line 252, in execute
edx.quince-rg.lms  |     return self._record(super().execute, sql, params)
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/debug_toolbar/panels/sql/tracking.py", line 177, in _record
edx.quince-rg.lms  |     return method(sql, params)
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 102, in execute
edx.quince-rg.lms  |     return super().execute(sql, params)
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 67, in execute
edx.quince-rg.lms  |     return self._execute_with_wrappers(
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
edx.quince-rg.lms  |     return executor(sql, params, many, context)
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 89, in _execute
edx.quince-rg.lms  |     return self.cursor.execute(sql, params)
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/utils.py", line 91, in __exit__
edx.quince-rg.lms  |     raise dj_exc_value.with_traceback(traceback) from exc_value
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/utils.py", line 89, in _execute
edx.quince-rg.lms  |     return self.cursor.execute(sql, params)
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 75, in execute
edx.quince-rg.lms  |     return self.cursor.execute(query, args)
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/cursors.py", line 179, in execute
edx.quince-rg.lms  |     res = self._query(mogrified_query)
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/cursors.py", line 330, in _query
edx.quince-rg.lms  |     db.query(q)
edx.quince-rg.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/MySQLdb/connections.py", line 255, in query
edx.quince-rg.lms  |     _mysql.connection.query(self, query)
edx.quince-rg.lms  | django.db.utils.DataError: (1406, "Data too long for column 'name' at row 1")
edx.quince-rg.lms  | [23/Apr/2024 11:26:00] "POST /api/user/v2/account/registration/ HTTP/1.1" 500 561223

Error 500 is returned to the user
500

I will also make a fix in Authn MFE so that a request with such a long name will not be sent. But this fix will protect the backend from errors in writing to the database.

In this case, a 400 response will be sent to the user:
400


PS: MR#1242 to Authn MFE

@DmytroAlipov DmytroAlipov requested a review from a team as a code owner April 23, 2024 12:04
@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Apr 23, 2024
@openedx-webhooks
Copy link

Thanks for the pull request, @DmytroAlipov! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@DmytroAlipov DmytroAlipov added the bug Report of or fix for something that isn't working as intended label Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Report of or fix for something that isn't working as intended open-source-contribution PR author is not from Axim or 2U
Projects
Status: Ready for Review
Development

Successfully merging this pull request may close these issues.

None yet

2 participants