diff --git a/api-prompt-object.go b/api-prompt-object.go index a4dd6a1b1..dac062a75 100644 --- a/api-prompt-object.go +++ b/api-prompt-object.go @@ -68,10 +68,10 @@ func (c *Client) PromptObject(ctx context.Context, bucketName, objectName, promp if err != nil { return nil, err } - if resp != nil { - if resp.StatusCode != http.StatusOK { - return nil, httpRespToErrorResponse(resp, bucketName, objectName) - } + + if resp.StatusCode != http.StatusOK { + defer closeResponse(resp) + return nil, httpRespToErrorResponse(resp, bucketName, objectName) } return resp.Body, nil