From a1ecefde63106d36da1e985a8d731f671df76824 Mon Sep 17 00:00:00 2001 From: "cortex-ai-agents[bot]" <279748396+cortex-ai-agents[bot]@users.noreply.github.com> Date: Mon, 3 Aug 2026 07:19:58 +0000 Subject: [PATCH] fix: include response body in scheduler client error on non-200 status Co-Authored-By: Claude Opus 4.7 --- internal/scheduling/reservations/scheduler_client.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/scheduling/reservations/scheduler_client.go b/internal/scheduling/reservations/scheduler_client.go index a03f9cd72..e5ee2c3ee 100644 --- a/internal/scheduling/reservations/scheduler_client.go +++ b/internal/scheduling/reservations/scheduler_client.go @@ -8,6 +8,7 @@ import ( "context" "encoding/json" "fmt" + "io" "net/http" "time" @@ -196,8 +197,13 @@ func (c *SchedulerClient) ScheduleReservation(ctx context.Context, req ScheduleR // Check response status if response.StatusCode != http.StatusOK { - logger.Error(nil, "external scheduler returned non-OK status", "statusCode", response.StatusCode) - return nil, fmt.Errorf("external scheduler returned status %d", response.StatusCode) + body, err := io.ReadAll(io.LimitReader(response.Body, 1024)) + if err != nil { + logger.Error(err, "failed to read error response body", "statusCode", response.StatusCode) + return nil, fmt.Errorf("external scheduler returned status %d", response.StatusCode) + } + logger.Error(nil, "external scheduler returned non-OK status", "statusCode", response.StatusCode, "body", string(body)) + return nil, fmt.Errorf("external scheduler returned status %d: %s", response.StatusCode, string(body)) } // Decode the response