Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions RELEASE.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Release Notes
=============

Version 0.56.6
--------------

- remove temporary code setting resource_category to resource_type_group (#2981)

Version 0.56.5 (Released March 04, 2026)
--------------

Expand Down
7 changes: 1 addition & 6 deletions learning_resources_search/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,7 @@ class FilterConfig:
"platform": FilterConfig("platform.code"),
"offered_by": FilterConfig("offered_by.code"),
"delivery": FilterConfig("delivery.code"),
# NOTE resource_category was renamed to resource_type_group
# Both fields contain the resource tab data for now so that
# we don't break search until a reindex finishes.
# A follow up pr will update the next line and populate
# the new resource_category field.
"resource_type_group": FilterConfig("resource_category"),
"resource_type_group": FilterConfig("resource_type_group"),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Removing the resource_category fallback field before a full re-index completes will cause searches filtering by resource_type_group to return incomplete results.
Severity: HIGH

Suggested Fix

Ensure that a full re-index of the search data is completed and the new index is live before deploying this code change. This will guarantee all documents have the resource_type_group field, preventing incomplete search results. Alternatively, delay the removal of the resource_category fallback logic until the re-index is confirmed to be finished in production.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: learning_resources_search/constants.py#L99

Potential issue: The code removes a temporary workaround that duplicated
`resource_type_group` data into the `resource_category` field. If this change is
deployed before a full OpenSearch re-index is completed, existing documents will not
have the `resource_type_group` field. When a user filters by `resource_type_group`, the
term query will not match these older documents, leading to silently incomplete search
results. This is a deployment-dependent issue; the bug manifests if the deployment
precedes the completion of the data migration.

Did we get this right? 👍 / 👎 to inform future reviews.

}

SEARCH_NESTED_FILTERS = {
Expand Down
4 changes: 0 additions & 4 deletions learning_resources_search/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,6 @@ def serialize_learning_resource_for_update(
resource_age_date and resource_age_date.year <= STALENESS_CUTOFF
) or (learning_resource_obj.completeness < COMPLETENESS_CUTOFF)

# NOTE - resource_category was renamed to resource_type_group
# The next line should be removed in a follow-up PR
serialized_data["resource_category"] = serialized_data["resource_type_group"]

return {
"resource_relations": {"name": "resource"},
"created_on": learning_resource_obj.created_on,
Expand Down
3 changes: 0 additions & 3 deletions learning_resources_search/serializers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,6 @@ def test_serialize_bulk_learning_resources(mocker):

for resource in resources:
resource_data = LearningResourceSerializer(instance=resource).data
resource_data["resource_category"] = resource_data["resource_type_group"]
data = {
"_id": mocker.ANY,
"resource_relations": mocker.ANY,
Expand Down Expand Up @@ -710,7 +709,6 @@ def test_serialize_learning_resource_for_bulk( # noqa: PLR0913

resource = LearningResource.objects.for_search_serialization().get(pk=resource.pk)
resource_data = LearningResourceSerializer(resource).data
resource_data["resource_category"] = resource_data["resource_type_group"]
assert serializers.serialize_learning_resource_for_bulk(resource) == {
"_id": resource.id,
"resource_relations": {"name": "resource"},
Expand Down Expand Up @@ -832,7 +830,6 @@ def test_serialize_course_numbers_for_bulk(
return_value=datetime(2024, 1, 1, 1, 1, 1, 0, tzinfo=UTC),
)
resource_data = LearningResourceSerializer(resource).data
resource_data["resource_category"] = resource_data["resource_type_group"]
expected_data = {
"_id": resource.id,
"resource_relations": {"name": "resource"},
Expand Down
2 changes: 1 addition & 1 deletion main/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from main.settings_pluggy import * # noqa: F403
from openapi.settings_spectacular import open_spectacular_settings

VERSION = "0.56.5"
VERSION = "0.56.6"

log = logging.getLogger()

Expand Down
Loading