Skip to content

Commit

Permalink
retry 409
Browse files Browse the repository at this point in the history
  • Loading branch information
phact committed Mar 21, 2024
1 parent bfdaed6 commit e43cbb9
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions impl/astra_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,19 @@ async def get_or_create_db(self):
return

def handle_response_errors(self, response: requests.Response) -> HandledResponse:
if response.status_code == 401:
# Forward the auth error to return from FastAPI
return HandledResponse(
status_code=401,
detail=f"{TOKEN_AUTH_FAILURE_MESSAGE}\nCould not access url: {e.response.url}. Detail: {e.response.text}",
retryable=False,
)
elif response.status_code == 409:
return HandledResponse(
status_code=409,
detail="Conflict",
retryable=True,
)
try:
response.raise_for_status()
except requests.HTTPError as e:
Expand All @@ -308,12 +321,6 @@ def handle_response_errors(self, response: requests.Response) -> HandledResponse
detail=f"{TOKEN_AUTH_FAILURE_MESSAGE}\nCould not access url: {e.response.url}. Detail: {e.response.text}",
retryable=False,
)
if e.response.status_code == 409:
return HandledResponse(
status_code=409,
detail="Conflict",
retryable=True,
)
try:
response_dict = response.json()
except json.JSONDecodeError:
Expand Down

0 comments on commit e43cbb9

Please sign in to comment.