Skip to content

Commit 93edea3

Browse files
adamjasokrasi-georgiev
authored andcommitted
Do not parse json on 204 responses (#476)
* Do not return BadResponse for no content Signed-off-by: Adam Jaso <[email protected]>
1 parent 0a8115f commit 93edea3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

api/prometheus/v1/api.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,10 +477,12 @@ func (c apiClient) Do(ctx context.Context, req *http.Request) (*http.Response, [
477477

478478
var result apiResponse
479479

480-
if err = json.Unmarshal(body, &result); err != nil {
481-
return resp, body, &Error{
482-
Type: ErrBadResponse,
483-
Msg: err.Error(),
480+
if http.StatusNoContent != code {
481+
if err = json.Unmarshal(body, &result); err != nil {
482+
return resp, body, &Error{
483+
Type: ErrBadResponse,
484+
Msg: err.Error(),
485+
}
484486
}
485487
}
486488

0 commit comments

Comments
 (0)