Recently Returned carousel missing from home page
Problem
The "Recently Returned" carousel no longer appears on the home page.
openlibrary.org
Reproducing the bug
- Go to ...openlibrary.org
- Do ...Look for the "recently returned" carousel.
- Expected behavior: It should be there.
- Actual behavior: It's not there.
Context
- Browser (Chrome, Safari, Firefox, etc):
- OS (Windows, Mac, etc):
- Logged in (Y/N):
- Environment (prod, dev, local): prod
Breakdown
Implementation Details (for maintainers)
Requirements Checklist
- [ ]
Related files
Stakeholders
Instructions for Contributors
- Please run these commands to ensure your repository is up to date before creating a new branch to work on this issue and each time after pushing code to Github, because the pre-commit bot may add commits to your PRs upstream.
All archive.org carousels are missing.
Hi! I’d like to help investigate this issue if it’s available.
I looked at the home page carousel path locally. The home page template still includes both IA-backed carousels:
Books We LoveRecently Returned
They appear to flow through:
openlibrary/templates/home/index.htmlopenlibrary/templates/home/custom_ia_carousel.htmlopenlibrary/plugins/openlibrary/home.pyopenlibrary/core/lending.py
I also tested the Archive.org advanced search query used for recently returned items, and it returns results. So my current understanding is that the issue is likely in Open Library’s fetch / formatting / caching path, or in how IA search results map back to Open Library edition records.
I tested a small candidate robustness fix locally: make get_ia_carousel_books() skip missing book records before formatting them, so one missing IA/Open Library edition mapping cannot break the whole carousel.
Focused tests pass:
docker compose run --rm home pytest openlibrary/plugins/openlibrary/tests/test_home.py -q
Result: 6 passed, 1 warning
Ruff also passes:
docker compose run --rm home ruff check openlibrary/plugins/openlibrary/home.py openlibrary/plugins/openlibrary/tests/test_home.py
Result: All checks passed!
I can continue investigating and open a PR if maintainers agree this is the right direction.
Note seeing this error in the testing logs; potentially related
2026-05-27 16:45:10 [29] [openlibrary.core.lending] [ERROR] get_available(http://archive.org/advancedsearch.php?q=openlibrary_work%3A%28%2A%29+AND+%28collection%3A%28inlibrary%29+OR+%28%21collection%3A%28printdisabled%29%29%29+AND+%28lending___available_to_browse%3Atrue+OR+lending___available_to_borrow%3Atrue%29+AND++language%3Aeng+AND+openlibrary_subject%3Aopenlibrary_staff_picks+AND+%21collection%3A%28no-preview%29&fl%5B%5D=identifier&fl%5B%5D=openlibrary_edition&fl%5B%5D=openlibrary_work&rows=18&page=1&output=json&service=metadata__unlimited&sort%5B%5D=lending___last_browse+desc)
Traceback (most recent call last):
File "/openlibrary/openlibrary/core/lending.py", line 301, in get_available_async
books = web.ctx.site.get_many([f"/books/{olid}" for olid in results.values()])
^^^^^^^^^^^^
AttributeError: 'ThreadedDict' object has no attribute 'site'
Hi! I can reproduce this locally and found the root cause — it matches @cdrini traceback.
get_available() is async, so it now runs on the AsyncBridge background thread. But lending.py still reads web.ctx.site, which is thread-local and empty on that thread → AttributeError, swallowed by the except Exception below → every IA carousel renders empty.
Fix (2 lines): use the site ContextVar instead. books = site.get().get_many([f"/books/{olid}" for olid in results.values()]) ContextVars (unlike thread-locals) propagate across the bridge — that's why req_context.get() already works.
Verified locally: traceback appears twice per homepage load before the change, zero after. Tests + ruff pass. (Complements #12804, which can't fix this since the error happens before any books are returned.)
Could I be assigned? @cdrini