From 7426501555d188dc4a39dfac002064aad7f3e8e3 Mon Sep 17 00:00:00 2001 From: gsinghpal Date: Thu, 4 Jun 2026 18:47:05 -0400 Subject: [PATCH] fix(fusion_shipping): UPS REST ship request sends malformed ReferenceNumber The UPS REST ship request wrapped the reference as {'Value': [{'Code':'BM','Value': picking.name}]}, but _ups_rest_prepare_shipping_data already builds reference_number as a list of {Code, Value} dicts. UPS expects ReferenceNumber to be such an object (or array) with a STRING Value and rejects the double-wrapped form on the ship call. This branch fires for every non-US/US (e.g. CA->CA, CA->US) shipment, so rating worked but label creation failed. Pass the list directly. Validated end-to-end against UPS production from a Canadian origin: rate + real label (tracking 1Z6W...6355, then voided). Co-Authored-By: Claude Opus 4.8 (1M context) --- fusion_shipping/api/ups_rest/request.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fusion_shipping/api/ups_rest/request.py b/fusion_shipping/api/ups_rest/request.py index 2c0990a1..e7a57617 100644 --- a/fusion_shipping/api/ups_rest/request.py +++ b/fusion_shipping/api/ups_rest/request.py @@ -431,9 +431,11 @@ class UPSRequest: (ship_from.country_id.code == 'US' and ship_to.country_id.code == 'US') or (ship_from.country_id.code == 'PR' and ship_to.country_id.code == 'PR') ): - request['ShipmentRequest']['Shipment']['ReferenceNumber'] = { - 'Value': shipment_info.get('reference_number') - } + # reference_number is already a list of {'Code', 'Value'} dicts + # (see _ups_rest_prepare_shipping_data). UPS expects ReferenceNumber + # to be such an object (or an array of them) with a string Value -- + # NOT {'Value': [, ...]}, which UPS rejects on the ship call. + request['ShipmentRequest']['Shipment']['ReferenceNumber'] = shipment_info.get('reference_number') # Shipments from US to CA or PR require extra info if ship_from.country_id.code == 'US' and ship_to.country_id.code in ['CA', 'PR']: