Skip to content

Commit

Permalink
fix: don't retry on 404 project not found (DEV-3362) (#857)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnussbaum committed Mar 5, 2024
1 parent 81508b0 commit 5c19f60
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/dsp_tools/utils/connection_live.py
Expand Up @@ -287,11 +287,16 @@ def _try_network_action(self, params: RequestParameters) -> Response:
return action()

def _handle_non_ok_responses(self, response: Response, request_url: str, retry_counter: int) -> None:
permanent_error_regexes = [
r"OntologyConstraintException",
r"DuplicateValueException",
r"Project '[0-9A-F]{4}' not found",
]
if "v2/authentication" in request_url and response.status_code == HTTP_UNAUTHORIZED:
raise BadCredentialsError("Bad credentials")

elif any(x in response.text for x in ["OntologyConstraintException", "DuplicateValueException"]):
msg = f"Error occurred due to user input, original message:\n{response.text}"
elif any(regex.search(x, response.text) for x in permanent_error_regexes):
msg = f"Error occurred due to user input. Original message:\n{response.text}"
raise InputError(msg)

elif not self._in_testing_environment():
Expand Down

0 comments on commit 5c19f60

Please sign in to comment.