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

Bibliotheca integration bad XML response (PP-1838) #2135

Merged
merged 1 commit into from
Oct 24, 2024

Conversation

jonathangreen
Copy link
Member

Description

Occasionally we are seeing an empty or bad XML response coming back from Bibliotheca. This causes the patron_activity.sync_patron_activity task to fail due to a lxml.etree.Error exception.

Since this is a bad / unexpected API response, I think it makes sense to wrap this in a RemoteIntegrationException. This change will mean that when we get a bad response back we will retry after #2132 goes in.

Motivation and Context

Trying to reduce the number of task failures we are seeing so that we can setup alerting when a celery task fails.

How Has This Been Tested?

  • Running tests in CI.

Checklist

  • I have updated the documentation accordingly.
  • All new and existing tests passed.

@jonathangreen jonathangreen added the bug Something isn't working label Oct 23, 2024
@jonathangreen jonathangreen requested a review from a team October 23, 2024 17:35
@jonathangreen jonathangreen changed the title Bibliotheca integration bad xml response (PP-1838) Bibliotheca integration bad XML response (PP-1838) Oct 23, 2024
Copy link

codecov bot commented Oct 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.82%. Comparing base (371492c) to head (aafd727).
Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2135   +/-   ##
=======================================
  Coverage   90.82%   90.82%           
=======================================
  Files         352      352           
  Lines       40854    40856    +2     
  Branches     8852     8852           
=======================================
+ Hits        37104    37106    +2     
  Misses       2442     2442           
  Partials     1308     1308           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@tdilauro tdilauro left a comment

Choose a reason for hiding this comment

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

Looks good! 🚀

One question below...

response.content
)
except Error as e:
# XML parse error from remote.
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there any cases for which we would NOT want to retry? If so, is there anything in the response that would allow us to distinguish cases where we would from those where we wouldn't? Although, RemoteIntegrationException seems like the right exception to raise, in any case.

Copy link
Member Author

Choose a reason for hiding this comment

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

We may find that case in the future, but I don't see any way to distinguish or not retry right now. From what I've seen its fairly random that their API just decides to respond with a 200 status code, but an empty response body. I think retrying is a reasonable thing to do in that case.

@jonathangreen jonathangreen merged commit 2e11018 into main Oct 24, 2024
20 checks passed
@jonathangreen jonathangreen deleted the bugfix/bibliotheca-api-response branch October 24, 2024 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants