Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions sync/clients/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,17 @@ def __init__(
)
def auth_flow(self, request: httpx.Request) -> Generator[httpx.Request, httpx.Response, None]:
with self._sync_lock:
# fetch with retry and exponential backoff
response = yield self.build_auth_request()
if response.status_code == httpx.codes.OK:
self.update_access_token(response)
elif response.status_code in self.retryable_status_codes:
if not self.cached_token.is_access_token_valid:
# fetch with retry and exponential backoff
response = yield self.build_auth_request()
if response.status_code == httpx.codes.OK:
self.update_access_token(response)
elif response.status_code in self.retryable_status_codes:
raise TryAgain()
else:
logger.error(f"{response.status_code}: Failed to authenticate")
if not self.cached_token.is_access_token_valid:
raise TryAgain()
Comment on lines +70 to 71
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the code ever reach this block?

Copy link
Contributor Author

@shughes-uk shughes-uk Nov 13, 2024

Choose a reason for hiding this comment

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

Sure after a status code not in the "retry status codes" list. It'll retry anyway 🤷‍♀️ . Basically the same as current behavior.

else:
logger.error(f"{response.status_code}: Failed to authenticate")
if not self.cached_token.is_access_token_valid:
raise TryAgain()
request.headers["Authorization"] = f"Bearer {self.cached_token.access_token}"
yield request

Expand Down
Loading