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

IN 1038 - handle more base RequestException #579

Merged
merged 1 commit into from
Aug 22, 2024

Conversation

ghukill
Copy link
Contributor

@ghukill ghukill commented Aug 21, 2024

Purpose and background context

A harvest recently failed (Sentry error) when the requests library threw a ConnectTimeout exception. We were formerly handling only HTTPError's, which this exception did not inherit from. This exception aborted the harvest instead of gracefully skipping and reporting record, and continuing.

How this addresses that need:

  • OAIClient.get_records() now catches more base RequestException which includes HTTP and connection errors

NOTE: with dependencies updated, it looks as pre-commit and/or linting has reformatted all the VCR cassette YAML files. Other than reformatting, they were not changed in this commit.

How can a reviewer manually see the effects of these changes?

The newly created test test_get_records_handles_requests_lib_errors demonstrates handling of both HTTPError and ConnectTimeout when thrown by requests library.

Includes new or updated dependencies?

YES

Changes expectations for external applications?

NO

What are the relevant tickets?

Developer

  • All new ENV is documented in README
  • All new ENV has been added to staging and production environments
  • All related Jira tickets are linked in commit message(s)
  • Stakeholder approval has been confirmed (or is not needed)

Code Reviewer(s)

  • The commit message is clear and follows our guidelines (not just this PR message)
  • There are appropriate tests covering any new functionality
  • The provided documentation is sufficient for understanding any new functionality introduced
  • Any manual tests have been performed or provided examples verified
  • New dependencies are appropriate or there were no changes

Why these changes are being introduced:

A harvest recently failed when the requests library threw a
ConnectTimeout exception.  We were formerly handling only HTTPErrors,
which this exception did not inherit from.  This exception aborted
the harvest instead of gracefully skipping and reporting record,
and continuing.

How this addresses that need:
* OAIClient.get_records() now catches more base RequestException which
includes HTTP and connection errors

Side effects of this change:
* Connection errors when retrieving a record will be logged and
skipped, and will not fail the full harvest.

Relevant ticket(s):
* https://mitlibraries.atlassian.net/browse/IN-1038
@coveralls
Copy link

Pull Request Test Coverage Report for Build 10494632383

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 9402153743: 0.0%
Covered Lines: 202
Relevant Lines: 202

💛 - Coveralls

Copy link
Contributor

@ehanson8 ehanson8 left a comment

Choose a reason for hiding this comment

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

Great fix and clear test!


@pytest.mark.parametrize(
"request_lib_exception",
[ConnectTimeout, HTTPError],
Copy link
Contributor

Choose a reason for hiding this comment

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

Really cool idea!

@ghukill ghukill merged commit ff749b6 into main Aug 22, 2024
4 checks passed
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.

4 participants