Skip to content

Commit 2545fae

Browse files
committed
fix: preserve legacy error body shape for readiness failures
1 parent 6fb5b40 commit 2545fae

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

src/error.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,17 @@ impl ResponseError for AppError {
3030
fn error_response(&self) -> HttpResponse {
3131
log_error!(TAG, "AppError occurred: {:?}", self);
3232

33-
// Check if this is a "not ready" error and return 503 instead of 500
33+
// Keep legacy error body shape for bindings clients that parse a plain string.
34+
// We still use 503 for readiness-related failures so callers can retry.
3435
let error_msg = self.0.to_string();
36+
let legacy_body = format!("Something went wrong: {error_msg}");
3537
if error_msg.contains("Backend not ready")
3638
|| error_msg.contains("not initialized")
3739
|| error_msg.contains("Initialization") {
38-
return HttpResponse::ServiceUnavailable()
39-
.json(serde_json::json!({
40-
"error": "Service temporarily unavailable",
41-
"message": error_msg,
42-
"retry_after": 5
43-
}));
40+
return HttpResponse::ServiceUnavailable().json(legacy_body);
4441
}
4542

46-
HttpResponse::InternalServerError().json(format!("Something went wrong: {error_msg}"))
43+
HttpResponse::InternalServerError().json(legacy_body)
4744
}
4845
}
4946

0 commit comments

Comments
 (0)