Fix 3,063 lists with subjects failing to index into solr#12873
Open
cdrini wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses Solr reindex failures for certain lists whose seed subjects are stored as subject pseudo-keys (e.g. subject:foo, place:bar) rather than /subjects/... paths, preventing errors during list indexing in the Solr updater.
Changes:
- Harden
seed_key_to_seed_type()to handle empty/non-path seed formats instead of crashing onkey.split("/")[1]. - Update list Solr faceting to skip/log unrecognized seed key types rather than failing the whole update.
- Add parametrized tests covering supported and invalid seed key formats.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| openlibrary/solr/updater/list.py | Adds warning + skip logic for invalid/unknown seed keys during seed facet grouping. |
| openlibrary/plugins/openlibrary/tests/test_lists.py | Adds parametrized tests for seed_key_to_seed_type() behavior across multiple seed formats. |
| openlibrary/plugins/openlibrary/lists.py | Adds validation/branching in seed_key_to_seed_type() to avoid IndexError on non-path seed formats. |
Comment on lines
+42
to
+47
| try: | ||
| seeds_by_type[seed_key_to_seed_type(seed)].append(seed) | ||
| except ValueError: | ||
| # seed_key_to_seed_type throws for unrecognized seed key types | ||
| logger.warning(f"Unrecognized seed key type for seed {seed}") | ||
| continue |
Comment on lines
+194
to
+199
| if not key: | ||
| raise ValueError("Seed key cannot be empty") | ||
|
|
||
| if "/" not in key: | ||
| # E.g. "subject:foo" or "place:bar" | ||
| return "subject" |
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.
Part of #11650
Was noticing errors for some lists that had subjects without the "/subjects" prefix.
Technical
Was noticing errors of this nature during the reindex:
Testing
Screenshot
Stakeholders