Skip to content

fix: don't break indexing on non-existant course#848

Merged
Kelketek merged 1 commit into
opencraft/ulmofrom
fox/tombstone-course-indexing-backport
Jul 6, 2026
Merged

fix: don't break indexing on non-existant course#848
Kelketek merged 1 commit into
opencraft/ulmofrom
fox/tombstone-course-indexing-backport

Conversation

@Kelketek

@Kelketek Kelketek commented Jun 30, 2026

Copy link
Copy Markdown
Member

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

@Kelketek Kelketek force-pushed the fox/tombstone-course-indexing-backport branch from 5ced8ab to 0031571 Compare July 3, 2026 14:53

@tecoholic tecoholic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@Kelketek Kelketek force-pushed the fox/tombstone-course-indexing-backport branch from 0031571 to 9a2e12c Compare July 6, 2026 14:55
@Kelketek Kelketek merged commit 7558ea7 into opencraft/ulmo Jul 6, 2026
48 checks passed
@Kelketek Kelketek deleted the fox/tombstone-course-indexing-backport branch July 6, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants