Bug when address is invalid?
Closed this issue · 4 comments
Hello,
I have an issue where a properly-formatted FROM address works fine, but a bogus FROM address ends up crashing with:
NoMethodError:
undefined method `each_byte' for nil:NilClass
The bogus address I was using (found this during testing trying to record a vcr cassette:
{:name=>"Kangaroo Court",
:address_line1=>"Bennelong Point",
:address_line2=>"Shell 1",
:city=>"Sydney",
:state=>"MN",
:country=>"US",
:zip=>"55447"}
An address that works:
{:name=>"MPS",
:address_line1=>"12450 Wayzata Blvd",
:address_line2=>"Suite 200",
:city=>"Minnetonka",
:state=>"MN",
:country=>"US",
:zip=>"55305"}
Our Call (practically straight from the docs):
response = @lob.letters.create(
description: "Demo Letter",
to: notification_recipient,
from: courthouse_mail_origination_point,
file: "https://s3-us-west-2.amazonaws.com/lob-assets/letter-goblue.pdf",
color: true
)
I feel strongly that the bogus address should be a properly trapped error and result in a 422 - Bad Request response.
Thanks & GO BADGERS!
Hey @DaveCollinsJr
We're looking into this now, but we can't seem to reproduce the error on our side. Make sure you're using version 1.12.0 of the wrapper though. We changed the way errors are handled with the new version of the API (2015-04-11) so that might be breaking on an older version of the wrapper.
@DaveCollinsJr v1.13.0 should work as well.
Strange I thought I was on the latest lob wrapper but was on 1.11. I've updated to 1.13 and will re-test and post here. Thanks!
Figured it out: Had nothing to do with the lob-wrapper version.
We were pulling the address from a REDIS cache and these were instances of ActiveSupport::SafeBuffer instead of Strings! Forcing them to strings solved the problem.