Skip to content

fix: update error handling to use httpx and improve caching logic#19

Open
ronibhakta1 wants to merge 2 commits intoArchiveLabs:mainfrom
ronibhakta1:fix/pyopds@_ol-#46
Open

fix: update error handling to use httpx and improve caching logic#19
ronibhakta1 wants to merge 2 commits intoArchiveLabs:mainfrom
ronibhakta1:fix/pyopds@_ol-#46

Conversation

@ronibhakta1
Copy link
Copy Markdown
Collaborator

Closes ArchiveLabs/pyopds2_openlibrary#54 ArchiveLabs/pyopds2_openlibrary#55 ArchiveLabs/pyopds2_openlibrary#53 ArchiveLabs/pyopds2_openlibrary#46

This pull request refactors error handling to use only the httpx library (removing all requests dependencies), improves language handling in search endpoints, updates group queries for more flexible ebook access filtering, and adds support for configuring the number of Uvicorn worker processes via environment variables. It also updates tests to match the new error handling and facet structure.

Error handling and dependency cleanup:

  • Refactored all upstream HTTP error handling to use only httpx exceptions, removing all usage of the requests library from both the application code and tests. This simplifies dependencies and ensures consistent error handling. [1] [2] [3] [4] [5]

Search and language improvements:

  • Added a language query parameter (defaulting to "eng") to the /search endpoint, allowing clients to specify preferred MARC language codes. This parameter is now logged, forwarded to the provider, and included in the response. [1] [2] [3]
  • Updated group queries on the homepage to use a dynamic ebook access filter (ea) based on the current mode, improving the accuracy of book groupings for different access types. [1] [2]

Caching and homepage behavior:

  • Adjusted homepage caching logic to treat /?mode=everything as equivalent to /, ensuring cache hits regardless of query parameter order and improving cache efficiency. [1] [2]

Deployment and concurrency:

  • Added support for configuring the number of Uvicorn worker processes via a WEB_CONCURRENCY environment variable, with Docker and configuration script updates to set a sensible default and allow overrides. [1] [2] [3]

Testing and facets:

  • Updated tests to match the new facet structure, removing sort facets and ensuring only the availability facet is present, with canonical labels and correct rel="self" usage for active links. [1] [2]

@ronibhakta1 ronibhakta1 requested a review from MarcCoquand April 3, 2026 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove the "sort" facet

1 participant