Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow up error while processing response of an unauthorized request #295

Closed
eric-christian opened this issue Sep 5, 2023 · 0 comments · Fixed by #324
Closed

Follow up error while processing response of an unauthorized request #295

eric-christian opened this issue Sep 5, 2023 · 0 comments · Fixed by #324

Comments

@eric-christian
Copy link

eric-christian commented Sep 5, 2023

Hello

I have noticed that when a request is made without proper authentication, the processing of the 401 response causes an exception.
There is a message attribute expected within the response which will be read into api_message. But the json response does not contain a message attribute. So api_message will be set to nil.
https://github.com/mailgun/mailgun-ruby/blob/master/lib/mailgun/exceptions/exceptions.rb#L53

Expected behavior

To have a Mailgun::CommunicationError raised.

Actual behavior

A TypeError is raised.

How to reproduce

To reproduce, do the following:
irb> Mailgun::Client.new('key-invalid').delete('my-random-domain/bounces/[email protected]')

/Users/eric/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/mailgun-ruby-1.2.10/lib/mailgun/exceptions/exceptions.rb:63:in `+': no implicit conversion of nil into String (TypeError)

      message = message + ': ' + api_message
                                 ^^^^^^^^^^^

Environment

ruby: 3.2.2
mailgun: 1.2.10
rails: 7.0.7.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant