edx-platform icon indicating copy to clipboard operation
edx-platform copied to clipboard

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

Open DmytroAlipov opened this issue 1 year ago • 4 comments

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 avatar Apr 23 '24 12:04 DmytroAlipov

Thanks for the pull request, @DmytroAlipov!

What's next?

Please work through the following steps to get your changes ready for engineering review:

:radio_button: Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.

:radio_button: Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads

:radio_button: Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

:radio_button: Let us know that your PR is ready for review:

Who will review my changes?

This repository is currently maintained by @openedx/wg-maintenance-edx-platform. Tag them in a comment and let them know that your changes are ready for review.

Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

:bulb: As a result it may take up to several weeks or months to complete a review and merge your PR.

openedx-webhooks avatar Apr 23 '24 12:04 openedx-webhooks

Hi @mphilbrick211 Friendly ping 😉 Also awaiting merge and related MR

DmytroAlipov avatar Aug 13 '24 07:08 DmytroAlipov

Hi @DmytroAlipov - thank you for your patience! We are awaiting review from a Core Contributor.

mphilbrick211 avatar Aug 15 '24 15:08 mphilbrick211

@mphilbrick211 I can help with this review :)

farhaanbukhsh avatar Sep 02 '24 12:09 farhaanbukhsh

Hey @DmytroAlipov I will review it later today :)

farhaanbukhsh avatar Oct 14 '24 06:10 farhaanbukhsh

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

edx-pipeline-bot avatar Nov 13 '24 15:11 edx-pipeline-bot

2U Release Notice: This PR has been deployed to the edX production environment.

edx-pipeline-bot avatar Nov 13 '24 15:11 edx-pipeline-bot

2U Release Notice: This PR has been deployed to the edX production environment.

edx-pipeline-bot avatar Nov 13 '24 15:11 edx-pipeline-bot