fix: don't break indexing on non-existant course#848
Merged
Conversation
5ced8ab to
0031571
Compare
tecoholic
approved these changes
Jul 6, 2026
tecoholic
left a comment
Member
There was a problem hiding this comment.
@Kelketek 👍 (Conditionally that the tests are fixed)
- I tested this: Created a dummy course
- I read through the code
- I checked for accessibility issues - NA
- Includes documentation
Code to create a dummy course for local testing. (AI disclosure: quickly generated using Claude Fable 5)
from opaque_keys.edx.keys import CourseKey
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
key = CourseKey.from_string("course-v1:Bogus+AdminTest+run1")
CourseOverview.objects.create(
id=key,
version=CourseOverview.VERSION, # NOT NULL column, no default
_location=key.make_usage_key("course", "course"), # NOT NULL column
display_name="Bogus Tombstone",
)
Comment on lines
+1236
to
+1242
|
|
||
| @override_settings(MEILISEARCH_ENABLED=True) | ||
| @patch('openeedx.core.djangoapps.content.search.api.log') | ||
| def test_graceful_handling_of_missing_course(self, mock_log, _mock_meilisearch) -> None: | ||
| key = CourseKey.from_string('course-v1:Bogus+CourseX+BogoCourse') | ||
| assert api.index_course(key) == [] # pylint: disable=use-implicit-booleaness-not-comparison | ||
| mock_log.error.assert_called_with("Course not found with key: %s", key) |
Member
There was a problem hiding this comment.
It looks like the test is indented one level too deep and there was a typo in the @patch.
Suggested change
| @override_settings(MEILISEARCH_ENABLED=True) | |
| @patch('openeedx.core.djangoapps.content.search.api.log') | |
| def test_graceful_handling_of_missing_course(self, mock_log, _mock_meilisearch) -> None: | |
| key = CourseKey.from_string('course-v1:Bogus+CourseX+BogoCourse') | |
| assert api.index_course(key) == [] # pylint: disable=use-implicit-booleaness-not-comparison | |
| mock_log.error.assert_called_with("Course not found with key: %s", key) | |
| @override_settings(MEILISEARCH_ENABLED=True) | |
| @patch('openedx.core.djangoapps.content.search.api.log') | |
| def test_graceful_handling_of_missing_course(self, mock_log, _mock_meilisearch) -> None: | |
| key = CourseKey.from_string('course-v1:Bogus+CourseX+BogoCourse') | |
| assert api.index_course(key) == [] # pylint: disable=use-implicit-booleaness-not-comparison | |
| mock_log.error.assert_called_with("Course not found with key: %s", key) |
0031571 to
9a2e12c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes an issue where indexing courses which have been tombstoned crashes. A fix already exists for this upstream, so this is a semantic backport. It can be dropped when upgrading to Verawood.
Internal ticket: https://tasks.opencraft.com/browse/BB-10959