Skip to content

Commit 18efa90

Browse files
committed
fix: differentiate MaxBytesError from other read failures in the InstallBackend handler
Signed-off-by: Dorin Geman <dorin.geman@docker.com>
1 parent e24fb26 commit 18efa90

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/inference/scheduling/http_handler.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,12 @@ type installBackendRequest struct {
349349
func (h *HTTPHandler) InstallBackend(w http.ResponseWriter, r *http.Request) {
350350
body, err := io.ReadAll(http.MaxBytesReader(w, r.Body, maximumOpenAIInferenceRequestSize))
351351
if err != nil {
352-
http.Error(w, "failed to read request body", http.StatusInternalServerError)
352+
var maxBytesError *http.MaxBytesError
353+
if errors.As(err, &maxBytesError) {
354+
http.Error(w, "request too large", http.StatusBadRequest)
355+
} else {
356+
http.Error(w, "failed to read request body", http.StatusInternalServerError)
357+
}
353358
return
354359
}
355360

0 commit comments

Comments
 (0)