openedx / openedx/openedx-ai-extensions

ISSUE: MeiliSearch update fails on problems creation

Open
#78 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
17
Forks
11
Avg merge
5h 33m
Merged PRs (30d)
4

Description

2025-12-23 04:41:36,863 ERROR 522 [celery_utils.logged_task] [user 4] [ip 172.20.0.1] logged_task.py:48 - [51a66e9a-8fa3-48bb-8036-cdf46edca2cd] failed due to Traceback (most recent call last):
  File "/openedx/venv/lib/python3.11/site-packages/celery/app/trace.py", line 453, in trace_task
    R = retval = fun(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/celery/app/autoretry.py", line 38, in run
    return task._orig_run(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/edx_django_utils/monitoring/internal/code_owner/utils.py", line 195, in new_function
    return wrapped_function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/edx-platform/openedx/core/djangoapps/content/search/tasks.py", line 102, in update_library_collection_index_doc
    api.upsert_library_collection_index_doc(collection_key)
  File "/openedx/edx-platform/openedx/core/djangoapps/content/search/api.py", line 723, in upsert_library_collection_index_doc
    if update_items:
       ^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'update_items' where it is not associated with a value

2025-12-23 04:41:36,863 ERROR 522 [celery.app.trace] [user 4] [ip 172.20.0.1] trace.py:267 - Task openedx.core.djangoapps.content.search.tasks.update_library_collection_index_doc[51a66e9a-8fa3-48bb-8036-cdf46edca2cd] raised unexpected: UnboundLocalError("cannot access local variable 'update_items' where it is not associated with a value")
Traceback (most recent call last):
  File "/openedx/venv/lib/python3.11/site-packages/celery/app/trace.py", line 453, in trace_task
    R = retval = fun(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/celery/app/autoretry.py", line 38, in run
    return task._orig_run(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/edx_django_utils/monitoring/internal/code_owner/utils.py", line 195, in new_function
    return wrapped_function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/edx-platform/openedx/core/djangoapps/content/search/tasks.py", line 102, in update_library_collection_index_doc
    api.upsert_library_collection_index_doc(collection_key)
  File "/openedx/edx-platform/openedx/core/djangoapps/content/search/api.py", line 723, in upsert_library_collection_index_doc
    if update_items:
       ^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'update_items' where it is not associated with a value

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in openedx/core/djangoapps/content/search/api.py at upsert_library_collection_index_doc, then trace its call from openedx/core/djangoapps/content/search/tasks.py. Reproduce library collection creation and verify that the MeiliSearch update completes without the reported UnboundLocalError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, search
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.