refactor: replace HTTParty with standard Ruby Net::HTTP#18
Conversation
Remove HTTParty dependency and refactor Claude client to use Ruby's standard Net::HTTP library. This change reduces external dependencies which were causing errors on some systems while maintaining the same functionality. The HTTP request handling is now implemented using built-in Ruby libraries, making the application more stable across different environments and reducing the dependency surface area.
| spec.executables = %w[committer] | ||
| spec.require_paths = ['lib'] | ||
|
|
||
| spec.add_dependency 'httparty', '~> 0.20' |
There was a problem hiding this comment.
Removing the httparty dependency here but still using it in the code will cause runtime errors. Make sure to update all usage of httparty or keep the dependency.
|
|
||
| require 'json' | ||
| require 'httparty' | ||
| require 'net/http' |
There was a problem hiding this comment.
Switching from HTTParty to standard library Net::HTTP is good for reducing dependencies, but ensure you're handling all error cases properly with the new implementation.
| request['content-type'] = 'application/json' | ||
| request['x-api-key'] = @config['api_key'] | ||
| request.body = body.to_json | ||
|
|
There was a problem hiding this comment.
The return value has changed. The previous HTTParty.post returned a Response object with various methods, but now you're returning a parsed JSON hash. Ensure all callers of this method can handle the new return type.
|
|
||
| response = http.request(request) | ||
| JSON.parse(response.body) | ||
| rescue JSON::ParserError |
There was a problem hiding this comment.
Consider adding more specific error handling for different HTTP status codes (like 401, 403, 429, 500) to provide better error messages.
Remove HTTParty dependency and refactor Claude client to use Ruby's standard Net::HTTP library. This change reduces external dependencies which were causing errors on some systems while maintaining the same functionality. The HTTP request handling is now implemented using built-in Ruby libraries, making the application more stable across different environments and reducing the dependency surface area.