Skip to content

Commit ff19296

Browse files
committed
CR from gemini
1 parent b527a9d commit ff19296

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

libs/server/kiln_server/custom_errors.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,14 @@ async def http_exception_handler(request: Request, exc: HTTPException):
8989

9090
@app.exception_handler(httpx.TimeoutException)
9191
async def timeout_error_handler(request: Request, exc: httpx.TimeoutException):
92+
logger.warning(
93+
f"Request timed out on {request.method} {request.url.path}",
94+
exc_info=exc,
95+
)
9296
return JSONResponse(
9397
status_code=status.HTTP_408_REQUEST_TIMEOUT,
9498
headers={"Access-Control-Allow-Origin": "*"},
95-
content={
96-
"message": "Request timed out. Please try again.",
97-
"raw_error": str(exc),
98-
},
99+
content={"message": "Request timed out. Please try again."},
99100
)
100101

101102
# Fallback error handler for any other exception

libs/server/kiln_server/test_custom_error.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,18 @@ def test_format_error_loc_with_empty_string():
109109

110110

111111
class TestTimeoutErrorHandler:
112-
def test_timeout_exception_returns_408(self, client):
113-
response = client.get("/timeout")
112+
def test_timeout_exception_returns_408(self, client_no_raise):
113+
response = client_no_raise.get("/timeout")
114114
assert response.status_code == 408
115115

116-
def test_timeout_exception_message(self, client):
117-
response = client.get("/timeout")
116+
def test_timeout_exception_message(self, client_no_raise):
117+
response = client_no_raise.get("/timeout")
118118
body = response.json()
119119
assert body["message"] == "Request timed out. Please try again."
120-
assert "raw_error" in body
120+
assert "raw_error" not in body
121121

122-
def test_timeout_exception_has_cors_header(self, client):
123-
response = client.get("/timeout")
122+
def test_timeout_exception_has_cors_header(self, client_no_raise):
123+
response = client_no_raise.get("/timeout")
124124
assert response.headers.get("access-control-allow-origin") == "*"
125125

126126
def test_other_exceptions_still_return_500(self, client_no_raise):

0 commit comments

Comments
 (0)