Skip to content

Commit 378bb79

Browse files
Merge pull request #816 from joshbranham/bug/reports-404-handled
SREP-2435: Handle 404 for a get report request better
2 parents a18781c + cf6e746 commit 378bb79

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/backplane/client.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"errors"
77
"fmt"
88
"io"
9+
"net/http"
910
"time"
1011

1112
backplaneapi "github.com/openshift/backplane-api/pkg/client"
@@ -125,6 +126,13 @@ func (c *Client) GetReport(ctx context.Context, reportID string) (*backplaneapi.
125126
}
126127
defer report.Body.Close()
127128

129+
if report.StatusCode == http.StatusNotFound {
130+
return nil, fmt.Errorf("report %s not found", reportID)
131+
} else if report.StatusCode != 200 {
132+
bodyBytes, _ := io.ReadAll(report.Body)
133+
return nil, fmt.Errorf("failure getting report, status: %d, body: %s", report.StatusCode, string(bodyBytes))
134+
}
135+
128136
err = json.NewDecoder(report.Body).Decode(&output)
129137
if err != nil {
130138
return output, fmt.Errorf("failed to unmarshal report: %w", err)

0 commit comments

Comments
 (0)