Skip to content

Commit

Permalink
EDX-5171 Fix the error when no response in DeleteRequest http func
Browse files Browse the repository at this point in the history
Not unmarshal to returnValuePointer if no response returned from http request.

Signed-off-by: Lindsey Cheng <beckysocute@gmail.com>
  • Loading branch information
lindseysimple committed Aug 16, 2024
1 parent 5d39b38 commit f364a61
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions clients/http/utils/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ func DeleteRequest(ctx context.Context, returnValuePointer interface{}, baseUrl
if err != nil {
return errors.NewCommonEdgeXWrapper(err)
}

if len(res) == 0 {
// no response body is returned from the http request
return nil
}

if err := json.Unmarshal(res, returnValuePointer); err != nil {
return errors.NewCommonEdgeX(errors.KindContractInvalid, "failed to parse the response body", err)
}
Expand Down

0 comments on commit f364a61

Please sign in to comment.