Skip to content

Commit

Permalink
Log error only on 5xx errors on predict
Browse files Browse the repository at this point in the history
  • Loading branch information
lferran committed Jun 17, 2024
1 parent bbeb605 commit dc20ba9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions nucliadb/src/nucliadb/search/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ async def check_response(self, resp: aiohttp.ClientResponse, expected_status: in
if resp.status == 402:
data = await resp.json()
raise LimitsExceededError(402, data["detail"])

try:
data = await resp.json()
try:
Expand All @@ -256,7 +255,10 @@ async def check_response(self, resp: aiohttp.ClientResponse, expected_status: in
aiohttp.client_exceptions.ContentTypeError,
):
detail = await resp.text()
logger.error(f"Predict API error at {resp.url}: {detail}")
if str(resp.status).startswith("5"):
logger.error(f"Predict API error at {resp.url}: {detail}")
else:
logger.info(f"Predict API error at {resp.url}: {detail}")
raise ProxiedPredictAPIError(status=resp.status, detail=detail)

@backoff.on_exception(
Expand Down

0 comments on commit dc20ba9

Please sign in to comment.