Skip to content

Commit 1fc1b2f

Browse files
committed
fix: Replace assert statements with AuthenticationError raises for unexpected None access tokens.
1 parent 8d7ac24 commit 1fc1b2f

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

amazon_creatorsapi/aio/auth.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,18 @@ async def get_token(self) -> str:
109109
"""
110110
if self.is_token_valid():
111111
# Token is cached and still valid, guaranteed to be str here
112-
assert self._access_token is not None # noqa: S101
112+
if self._access_token is None:
113+
msg = "Token should be valid at this point"
114+
raise AuthenticationError(msg)
113115
return self._access_token
114116

115117
# Need to refresh - use lock to prevent concurrent refreshes
116118
async with self._lock:
117119
# Double-check after acquiring lock
118120
if self.is_token_valid():
119-
assert self._access_token is not None # noqa: S101
121+
if self._access_token is None:
122+
msg = "Token should be valid at this point"
123+
raise AuthenticationError(msg)
120124
return self._access_token
121125
return await self.refresh_token()
122126

0 commit comments

Comments
 (0)