mailjet / mailjet-gem

[API v3] Mailjet official Ruby GEM
https://dev.mailjet.com
Other
130 stars 72 forks source link

Remove password and API key from exception #248

Closed tsujigiri closed 11 months ago

tsujigiri commented 1 year ago

When the Mailjet API rejects a request and the client is raising an exception, it includes a string representation of the RestClient instance, including API key and password. Maybe it would be a good idea to remove those from the RestClient instance, before, so it doesn't spread wherever the exception goes (logs, 3rd party services). Example:

Mailjet::ApiError: error 401 while sending #<RestClient::Resource:0x000000010b1327c8 @url="https://api.mailjet.com/v3.1/send", @block=nil, @options={:public_operations=>[:post], :read_only=>nil, :perform_api_call=>true, :open_timeout=>nil, :read_timeout=>nil, :user=>"super secret", :password=>"oh no", :content_type=>"application/json"}> to https://api.mailjet.com/v3.1/send with {"Messages"=>[{"From"=>{"Email"=>"user@example.com", "Name"=>"Me"}, "To"=>[{"Email"=>"user@example.com", "Name"=>"You"}], "Subject"=>"My first Mailjet Email!", "TextPart"=>"Greetings from Mailjet!", "HTMLPart"=>"<h3>Dear passenger 1, welcome to <a href='https://www.mailjet.com/'>Mailjet</a>!</h3><br />May the delivery force be with you!"}]}