DataDog / dogapi-rb

Ruby client for Datadog's API
https://www.datadoghq.com
BSD 3-Clause "New" or "Revised" License
96 stars 88 forks source link

Response codes are handled as integers, but are strings #234

Closed mikesaelim closed 3 years ago

mikesaelim commented 4 years ago

Describe the bug I think Net::HTTP is returning response codes as strings. The call to Net::HTTP.request() here returns a Net::HTTPResponse object, which has a string code: Net::HTTPResponse.

However, it looks like the client handles the response code as if it were an integer, in a number of places. For example, here and here. The FakeResponse in the specs also gets initialized with integer response codes.

If I'm not mistaken, this means 204s and redirects might not be handled properly. If you concur, I'd be willing to submit a PR to fix how the response code is handled.

To Reproduce Steps to reproduce the behavior:

  1. Call a method on the client that calls the Datadog API
  2. Observe that the returned response code is a string.

Environment and Versions (please complete the following information): Using version 1.40 of this client.

github-actions[bot] commented 4 years ago

Thanks for your contribution!

This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.

If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of this project.

  2. Comment that the issue is still reproducible and include updated details requested in the issue template.

mikesaelim commented 4 years ago

Yep, it's still like this.

mikesaelim commented 3 years ago

Thanks @zippolyte !