Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ekir 219 handle 502 errors when loaning #134

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

natlibfi-kaisa
Copy link
Contributor

@natlibfi-kaisa natlibfi-kaisa commented Feb 12, 2025

Description

Handle the case where we think there are available licenses, but when we reach out to the content provider, it turns out there are no licenses available.

Motivation and Context

We were getting a lot of 502 responses with no specific debugging info. It turned out that the content provider was responding with a application/api-problem+json and not a application/problem+json when there were no copies left when trying to checkout a book. The relevant code is in api/odl.py.
This PR implements OPDS2 + ODL Handle case where no licenses are available solution together with their Refactor BadResponseException.

During the implementation, some needed refactoring of how HTTP responses in general were needed. These changes were done in core/util/http.py which had some minor changes needed in api/overdrive.py, customlists/customlist_import.py, core/opds2_import.py and core/opds_import.py.

How Has This Been Tested?

Locally tested and unit tests.

Checklist

  • I have updated the documentation accordingly.
  • All new and existing tests passed.
  • Transifex translators have been notified. NEEDS UPDATE but the translation should be in Transifex.

@natlibfi-kaisa natlibfi-kaisa force-pushed the EKIR-219-Handle-502-errors-when-loaning branch 2 times, most recently from edefb05 to 7f3697f Compare February 12, 2025 10:30
@natlibfi-kaisa natlibfi-kaisa force-pushed the EKIR-219-Handle-502-errors-when-loaning branch from 7f3697f to c45d0e5 Compare February 12, 2025 10:53
@@ -209,8 +209,6 @@ def _borrow(self, patron, credential, pool, mechanism):
result = e.as_problem_detail_document(debug=False)
except AuthorizationBlocked as e:
result = e.as_problem_detail_document(debug=False)
except CannotLoan as e:
result = CHECKOUT_FAILED.with_debug(str(e))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tämä liittyy siihen syksyllä tehtyyn ongelmaan, jossa kirjaa ei ollutkaan saatavilla, kun käyttäjä yritti lainata hänelle varatun kirjan.

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.

2 participants