Error "MongoContent matching query does not exist" during migration
Open
@angonz is already working on this.
Since May 5, 2025.
- Dominant language
- Python
- Stars
- 5
- Forks
- 26
- Avg merge
- 7d 11h
- Merged PRs (30d)
- 2
Description
When running forum_migrate_course_from_mongodb_to_mysql --no-toggle all, I got the following stack trace:
Traceback (most recent call last):
File "/openedx/edx-platform/./manage.py", line 106, in <module>
execute_from_command_line([sys.argv[0]] + django_args)
File "/openedx/venv/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/openedx/venv/lib/python3.11/site-packages/django/core/management/__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/openedx/venv/lib/python3.11/site-packages/django/core/management/base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "/openedx/venv/lib/python3.11/site-packages/django/core/management/base.py", line 458, in execute
output = self.handle(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/venv/lib/python3.11/site-packages/forum/management/commands/forum_migrate_course_from_mongodb_to_mysql.py", line 48, in handle
migrate_read_states(db, course_id)
File "/openedx/venv/lib/python3.11/site-packages/forum/migration_helpers.py", line 253, in migrate_read_states
thread_id = MongoContent.objects.get(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/venv/lib/python3.11/site-packages/django/db/models/manager.py", line 87, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/venv/lib/python3.11/site-packages/django/db/models/query.py", line 637, in get
raise self.model.DoesNotExist(
forum.backends.mysql.models.MongoContent.DoesNotExist: MongoContent matching query does not exist.
This was caused because one of the threads of the read states does not exist in the MongoContent table.
The exception is raised by the first() function after the find here:
mongo_content = MongoContent.objects.filter(
mongo_id=thread_id
).first()
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.