Long URLs can cause the launch command to crash
CodeWithEmad opened this issue · 2 comments
I encounter this issue while creating an organization with a long URL. Django's Site model has a 50 character limit for it's name
field and creating a new Site Configuration in tutor-discovery jobs, the job will fail on long URLs.
# After successfully creating all dot_applications for dev and prod envs:
2024-10-23 08:16:31,186 INFO 241 [openedx.core.djangoapps.oauth_dispatch.management.commands.create_dot_application] [user None] [ip None] create_dot_application.py:97 - Updated discovery application with id: 6, client_id: discovery, and client_secret: HNgW8PWh
2024-10-23 08:16:31,195 INFO 241 [openedx.core.djangoapps.oauth_dispatch.management.commands.create_dot_application] [user None] [ip None] create_dot_application.py:117 - Updated application access for discovery with scopes: user_id
2024-10-23 08:16:36,208 WARNING 283 [py.warnings] [user None] [ip None] warnings.py:109 - /openedx/edx-platform/xmodule/discussion_block.py:15: DeprecatedPackageWarning: Please use import xblock.utils.resources instead of xblockutils.resources because the 'xblock-utils' package has been deprecated and migrated to within 'xblock' package.
from xblockutils.resources import ResourceLoader
2024-10-23 08:16:36,209 WARNING 283 [py.warnings] [user None] [ip None] warnings.py:109 - /openedx/edx-platform/xmodule/discussion_block.py:16: DeprecatedPackageWarning: Please use import xblock.utils.studio_editable instead of xblockutils.studio_editable because the 'xblock-utils' package has been deprecated and migrated to within 'xblock' package.
from xblockutils.studio_editable import StudioEditableXBlockMixin
2024-10-23 08:16:38,025 WARNING 283 [py.warnings] [user None] [ip None] warnings.py:109 - /openedx/venv/lib/python3.8/site-packages/drag_and_drop_v2/drag_and_drop_v2.py:28: DeprecatedPackageWarning: Please use import xblock.utils.settings instead of xblockutils.settings because the 'xblock-utils' package has been deprecated and migrated to within 'xblock' package.
from xblockutils.settings import ThemableXBlockMixin, XBlockWithSettingsMixin
2024-10-23 08:16:38,032 WARNING 283 [py.warnings] [user None] [ip None] warnings.py:109 - /openedx/venv/lib/python3.8/site-packages/google_drive/google_docs.py:14: DeprecatedPackageWarning: Please use import xblock.utils.publish_event instead of xblockutils.publish_event because the 'xblock-utils' package has been deprecated and migrated to within 'xblock' package.
from xblockutils.publish_event import PublishEventMixin
2024-10-23 08:16:38,072 WARNING 283 [py.warnings] [user None] [ip None] warnings.py:109 - /openedx/venv/lib/python3.8/site-packages/problem_builder/mixins.py:10: DeprecatedPackageWarning: Please use import xblock.utils.helpers instead of xblockutils.helpers because the 'xblock-utils' package has been deprecated and migrated to within 'xblock' package.
from xblockutils.helpers import child_isinstance
2024-10-23 08:16:38,812 INFO 283 [openedx.core.djangoapps.oauth_dispatch.management.commands.create_dot_application] [user None] [ip None] create_dot_application.py:97 - Updated discovery-sso application with id: 7, client_id: discovery-sso, and client_secret: s0Cd0oxU
2024-10-23 08:16:38,820 INFO 283 [openedx.core.djangoapps.oauth_dispatch.management.commands.create_dot_application] [user None] [ip None] create_dot_application.py:117 - Updated application access for discovery-sso with scopes: user_id
Traceback (most recent call last):
File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 75, in execute
return self.cursor.execute(query, args)
File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 179, in execute
res = self._query(mogrified_query)
File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 330, in _query
db.query(q)
File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/connections.py", line 255, in query
_mysql.connection.query(self, query)
MySQLdb.DataError: (1406, "Data too long for column 'name' at row 1")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/openedx/bin/site-configuration", line 81, in <module>
main()
File "/openedx/bin/site-configuration", line 41, in main
args.func(args)
File "/openedx/bin/site-configuration", line 47, in set_command
configuration = get_site_configuration(args.domain)
File "/openedx/bin/site-configuration", line 64, in get_site_configuration
site.save()
File "/openedx/venv/lib/python3.8/site-packages/django/db/models/base.py", line 814, in save
self.save_base(
File "/openedx/venv/lib/python3.8/site-packages/django/db/models/base.py", line 877, in save_base
updated = self._save_table(
File "/openedx/venv/lib/python3.8/site-packages/django/db/models/base.py", line 990, in _save_table
updated = self._do_update(
File "/openedx/venv/lib/python3.8/site-packages/django/db/models/base.py", line 1054, in _do_update
return filtered._update(values) > 0
File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 1231, in _update
return query.get_compiler(self.db).execute_sql(CURSOR)
File "/openedx/venv/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1984, in execute_sql
cursor = super().execute_sql(result_type)
File "/openedx/venv/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1562, in execute_sql
cursor.execute(sql, params)
File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 67, in execute
return self._execute_with_wrappers(
File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
File "/openedx/venv/lib/python3.8/site-packages/django/db/utils.py", line 91, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 75, in execute
return self.cursor.execute(query, args)
File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 179, in execute
res = self._query(mogrified_query)
File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 330, in _query
db.query(q)
File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/connections.py", line 255, in query
_mysql.connection.query(self, query)
django.db.utils.DataError: (1406, "Data too long for column 'name' at row 1")
The fun part is that running launch
command for the second time doesn't raise the issue.
I believe changing
tutor/tutor/templates/build/openedx/bin/site-configuration
Lines 63 to 64 in 97e9fa4
should do the trick.
OS: Ubuntu 22.04
tutor: 17.0.6
tutor-discovery: 17.0.1
The fun part is that running launch command for the second time doesn't raise the issue.
How so? It seems very weird.
It's not weird at all; the name is only set when the Site object is created.
tutor/tutor/templates/build/openedx/bin/site-configuration
Lines 62 to 64 in 97e9fa4
On the first attempt, it reaches this block, but subsequent tries only access the site by domain.