Repository navigation
Sem-ver: bugfix Fail over to secondary key repository on network errors and timeouts - #192
Open
utkarshpatwa393-sys wants to merge 1 commit into
Conversation
…rs and timeouts (atlassian#104) Signed-off-by: Utkarsh patwa <utkarshpatwa393@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #104.
Problem
HTTPSMultiRepositoryPublicKeyRetriever.handle_retrieval_exceptionhandles errors when querying multiple key repositories. When a key repository encounters a network-level error (e.g.,requests.exceptions.ConnectionError,requests.exceptions.Timeout, or socketConnectionResetError),exception.status_codeisNone.The previous check evaluated:
Because
status_codewasNone, the retriever raisedPublicKeyRetrieverExceptionimmediately instead of failing over to subsequent fallback key repositories, defeating the purpose of multi-repository fallback during network connectivity glitches or timeouts.Changes
HTTPSMultiRepositoryPublicKeyRetriever.handle_retrieval_exception:status_code is not None: raises immediately only for client errors (< 500) and fails over for server errors (>= 500).status_code is None: checksoriginal_exceptionagainst(RequestException, ConnectionError, OSError)to permit failover on transport and timeout errors while re-raising unexpected/non-network failures.atlassian_jwt_auth/tests/test_public_key_provider.py:test_retrieve_with_timeout_error: verifies failover to the secondary repository on arequests.exceptions.Timeout.test_retrieve_with_404_error_raises: verifies 404 client errors continue to raise immediately without unwarranted failover.Verification
pytest atlassian_jwt_auth/tests/-> 97 passed in 4.09sruff check atlassian_jwt_auth/key.py atlassian_jwt_auth/tests/test_public_key_provider.py-> All checks passed