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

Exception raised when trying to inspect or get message from Plaid::ApiError #481

Closed
enriquez opened this issue Dec 4, 2023 · 5 comments
Closed

Comments

@enriquez
Copy link

enriquez commented Dec 4, 2023

We have some specs that simulate Plaid::ApiErrors by doing something like this

Plaid::ApiError.new(
  code: 400, response_body: {
    error_code: 'INVALID_WEBHOOK_VERIFICATION_KEY_ID',
    error_type: 'INVALID_INPUT'
  }.to_json
)

The problem is when we try to rescue and read the message

rescue Plaid::ApiError => e
  puts e.message
end

An exception is raised

output error: #<NoMethodError: undefined method `+' for {:code=>400, :response_body=>"{\"error_code\":\"INVALID_WEBHOOK_VERIFICATION_KEY_ID\",\"error_type\":\"INVALID_INPUT\"}"}:Hash>

I expect a friendly message instead

"Error message: the server returns an error\nHTTP status code: 400\nResponse body: {\"error_code\":\"INVALID_WEBHOOK_VERIFICATION_KEY_ID\",\"error_type\":\"INVALID_INPUT\"}"

Something changed between v23 and v24 here which is causing the new exception:
https://github.com/plaid/plaid-ruby/blame/80cde7efe279d18e50fe14366be388bec0d3cf53/lib/plaid/api_error.rb#L28C9-L28C9

@phoenixy1
Copy link

phoenixy1 commented Dec 4, 2023

Oh how embarrassing -- it looks like this was introduced in 24.1.0 where we went to ruby 6.3. It looks like, when upgrading the template generator, I accidentally edited the wrong line of the template file, and apparently we don't have any tests that would catch this. I have a PR in progress that should fix the issue in the next clib release. Thank you for the report!

@phoenixy1
Copy link

@enriquez in the mean time, would it be possible for you to try moving the line "@message = arg" from line 28 to right after line 35 in the api_error.rb file and let us know if that fixes the issue for you?

@marvs
Copy link

marvs commented Dec 14, 2023

We are encountering the same error, rolling back to version 23 for now until the fix is released. Thanks for your work here!

@pdx91
Copy link

pdx91 commented Dec 15, 2023

@enriquez in the mean time, would it be possible for you to try moving the line "@message = arg" from line 28 to right after line 35 in the api_error.rb file and let us know if that fixes the issue for you?

@phoenixy1 I stumbled upon this issue and your suggestion fixed the issue for me. I'm able to inspect the error without the undefined method + error

@phoenixy1
Copy link

This should now be fixed with today's release. Please comment if it is still happening after upgrading!

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

No branches or pull requests

4 participants