Skip to content

Commit 245b861

Browse files
fix: reindex_studio could crash if an XBlock child isn't loadable (#37177)
Co-authored-by: Chris Chávez <xnpiochv@gmail.com>
1 parent 1aa8627 commit 245b861

File tree

1 file changed

+4
-0
lines changed
  • openedx/core/djangoapps/content/search

1 file changed

+4
-0
lines changed

openedx/core/djangoapps/content/search/api.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
from openedx.core.djangoapps.content.search.models import IncrementalIndexCompleted, get_access_ids_for_request
4141
from openedx.core.djangoapps.content_libraries import api as lib_api
4242
from xmodule.modulestore.django import modulestore
43+
from xmodule.modulestore.exceptions import ItemNotFoundError
4344

4445
from .documents import (
4546
Fields,
@@ -278,6 +279,9 @@ def _recurse_children(block, fn, status_cb: Callable[[str], None] | None = None)
278279
for child_id in block.children:
279280
try:
280281
child = block.get_child(child_id)
282+
if child is None:
283+
# XBlocks with XModuleMixin will return None from get_child() instead of raising an exception :/
284+
raise ItemNotFoundError(f"block.get_child() from {block.usage_key} failed to load child {child_id}")
281285
except Exception as err: # pylint: disable=broad-except
282286
log.exception(err)
283287
if status_cb is not None:

0 commit comments

Comments
 (0)