Fix embeddings healthcheck missing-summaries filter - #3686
Merged
Conversation
…ries get_unprocessed_content_file_ids(self, overwrite, learning_resource_ids=None, content_file_ids=None) was being called with a queryset passed positionally, which landed in the `overwrite` parameter instead of `learning_resource_ids`. Because a non-empty queryset is truthy, this silently set overwrite=True, skipping the "only unprocessed" filter, and `learning_resource_ids` was never passed at all, so the require_summaries=True scoping was lost entirely. The embeddings_healthcheck Sentry alert this feeds was therefore counting already-summarized content files across every learning resource, not just missing summaries for resources that require them. Pass both arguments as keywords, and short-circuit when no learning resources currently require summaries, since get_unprocessed_content_file_ids treats an empty learning_resource_ids list the same as None (no restriction) rather than "match nothing". Flagged by Sentry's bug-prediction bot on #3683 as a pre-existing issue unrelated to that PR's changes. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
OpenAPI ChangesNo changes detected Unexpected changes? Ensure your branch is up-to-date with |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a bug in the embeddings_healthcheck path where _missing_summaries() was passing a LearningResource queryset positionally into ContentSummarizer.get_unprocessed_content_file_ids, causing incorrect scoping and effectively treating all content files as “missing summaries” in Sentry.
Changes:
- Pass
overwrite=Falseandlearning_resource_ids=...as keyword arguments toget_unprocessed_content_file_idsto avoid positional mis-binding. - Add a short-circuit in
_missing_summaries()to return[]when no learning resources require summaries (preventing an unintended “scan everything” behavior). - Add regression tests ensuring the healthcheck excludes already-summarized content files and is scoped to
require_summaries=Trueresources.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| vector_search/tasks.py | Fixes _missing_summaries() argument binding and adds an empty-scope short-circuit to keep the healthcheck correctly scoped. |
| vector_search/tasks_test.py | Adds regression coverage for the corrected scoping and overwrite behavior in embeddings_healthcheck. |
shanbady
self-requested a review
July 27, 2026 19:01
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.
What are the relevant tickets?
N/A
Description (What does it do?)
_missing_summaries()invector_search/tasks.pycallsContentSummarizer.get_unprocessed_content_file_ids(self, overwrite, learning_resource_ids=None, content_file_ids=None), but was passing aLearningResourcequeryset positionally:That queryset landed in the
overwriteparameter instead oflearning_resource_ids. Since a non-empty queryset is truthy, this silently setoverwrite=True, which skips the "only unprocessed" filter (Q(summary="") | Q(flashcards=[])) insideget_unprocessed_content_file_ids. And becauselearning_resource_idswas never actually passed, therequire_summaries=Truescoping was lost entirely.The net effect: the
embeddings_healthcheckSentry alert this feeds (vector_search/tasks.py) was counting every content file across every learning resource — including ones that already have summaries and ones from resources that don't even require summaries — as "missing," rather than just genuinely unprocessed content on resources that require summaries.Fix: pass both arguments as keywords (
overwrite=False,learning_resource_ids=resource_ids). Also added a short-circuit for the case where no learning resources currently require summaries —get_unprocessed_content_file_idstreats an emptylearning_resource_idslist the same asNone(no restriction) rather than "match nothing," so without the short-circuit that edge case would still fall through to scanning every resource.This was flagged by Sentry's bug-prediction bot as a review comment on #3683 — it's a pre-existing bug (introduced in commit
3ba27bdc4e, 2025-11-07) unrelated to that PR's changes, so it's being fixed here separately.Screenshots (if appropriate):
N/A - no UI changes
How can this be tested?
Added two regression tests to
vector_search/tasks_test.py:test_embeddings_healthcheck_excludes_already_summarized— a content file that already has a summary and flashcards should not be counted as missing.test_embeddings_healthcheck_summaries_scoped_to_require_summaries— a content file belonging to a learning resource withrequire_summaries=Falseshould not be counted as missing.Both fail against the old code (the first because
overwriteends up truthy, the second becauselearning_resource_idsis never applied) and pass with the fix.Ran the full
vector_search/tasks_test.pysuite:docker compose run --rm web uv run pytest vector_search/tasks_test.py -q— 45 passed, including the existingtest_embeddings_healthcheck_missing_summariestest.ruff check --select F401,F821andruff format --diffare clean on both touched files.Additional Context
No behavior change outside of
_missing_summaries()/ theembeddings_healthchecktask — this only affects what gets reported to Sentry, not any content-processing task itself.