shipper_number gets set to "", which (being a truthy value) results in "Missing/Invalid Shipper/ShipperNumber" error response from UPS #57

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants

I've been using ActiveShipping with UPS in the past without problems until I upgraded to Spree 1.3. I checked my active_shipping_wiredump.log and confirmed that it has never included a <ShipperNumber> node in the request before. It was only after upgrading to Spree 1.3 that it started including that node and we started seeing this error.

Even though this preference is defined to have a nil default:

    preference :shipper_number, :string, :default => nil

somehow Spree::ActiveShipping::Config[:shipper_number] ended up getting set to "". I suspect it was probably set to "" when I edited the Active Shipping settings in the backend using the new /admin/active_shipping_settings page, since that page submits all settings as strings to the controller.

When Spree::ActiveShipping::Config[:shipper_number] is "", an empty ShipperNumber node is added to the request, resulting in a "Missing/Invalid Shipper/ShipperNumber" error response from UPS.

The solution seems to be to either prevent this setting from ever being set to "" to begin with — or handling the "" case and treating the same as nil.

By adding .presence, we can have it treat a "" value as nil so that it will skip adding the <ShipperNumber> node node when shipper_number is "" instead of treating "" as a truthy value.

When Spree::ActiveShipping::Config[:shipper_number] is "", an empty S…
…hipperNumber node is added to the

request, resulting in a "Missing/Invalid Shipper/ShipperNumber" error response from UPS.

By adding .presence, we can have it treat a "" value as nil so that it will skip adding the
ShipperNumber node when shipper_number is "" instead of treating "" as a truthy value.

@radar radar closed this in c85c26b Feb 1, 2013

radar added a commit that referenced this pull request Feb 1, 2013

When Spree::ActiveShipping::Config[:shipper_number] is "", an empty S…
…hipperNumber node is added to the request, resulting in a "Missing/Invalid Shipper/ShipperNumber" error response from UPS.

By adding .presence, we can have it treat a "" value as nil so that it will skip adding the
ShipperNumber node when shipper_number is "" instead of treating "" as a truthy value.

Fixes #57

radar added a commit that referenced this pull request Feb 1, 2013

When Spree::ActiveShipping::Config[:shipper_number] is "", an empty S…
…hipperNumber node is added to the request, resulting in a "Missing/Invalid Shipper/ShipperNumber" error response from UPS.

By adding .presence, we can have it treat a "" value as nil so that it will skip adding the
ShipperNumber node when shipper_number is "" instead of treating "" as a truthy value.

Fixes #57
Contributor

radar commented Feb 1, 2013

Merged. Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment