InvalidArgumentException: Invalid weight unit "" provided. in Drupal\physical\WeightUnit::assertExists()

Created on 1 January 2025, about 2 months ago

Problem/Motivation

We ship products world wide and have issues with address/weight validation.

Add item to cart and complete address information.
Upon completion following error shows on top:
"Oops, something went wrong. Check your browser's developer console for more details."

Checked developer console and following error are shown:

Failed to load resource: the server responded with a status of 500 ()

Drupal.AjaxError
message
:
"\nAn AJAX HTTP error occurred.\nHTTP Result Code: 500\nDebugging information follows.\nPath: /checkout/5232/order_information?ajax_form=1\nStatusText: error\nResponseText: The website encountered an unexpected error. Try again later."
name
:
"AjaxError"

Uncaught (in promise) Error: Could not establish connection. Receiving end does not exist.

Verified the weight unit in shipping method and appears to be correct.
Verified the product weight in product variation and there are no issues.
Verified the countries are indeed set in shipping method.
Tested same product using different addresses:
Addresses that are known to be working, (e.g. US/UK/Australia/Canada) the error goes away.
Addresses that are tested to have issues (Japan, Brunei) the errors will appear.

In DB log the following errors are showing.

InvalidArgumentException: Invalid weight unit "" provided. in Drupal\physical\WeightUnit::assertExists() (line 68 of /public_html/modules/contrib/physical/src/WeightUnit.php).

#0 /public_html/modules/contrib/physical/src/WeightUnit.php(42): Drupal\physical\WeightUnit::assertExists()
#1 /public_html/modules/contrib/physical/src/Measurement.php(105): Drupal\physical\WeightUnit::getBaseFactor()
#2 /public_html/modules/contrib/commerce_shipping/src/Plugin/Commerce/Condition/ShipmentWeight.php(140): Drupal\physical\Measurement->convert()
#3 /public_html/modules/contrib/commerce/src/ConditionGroup.php(86): Drupal\commerce_shipping\Plugin\Commerce\Condition\ShipmentWeight->evaluate()
#4 /public_html/modules/contrib/commerce_shipping/src/Entity/ShippingMethod.php(252): Drupal\commerce\ConditionGroup->evaluate()
#5 /public_html/modules/contrib/commerce_shipping/src/ShippingMethodStorage.php(39): Drupal\commerce_shipping\Entity\ShippingMethod->applies()
#6 /public_html/modules/contrib/commerce_shipping/src/ShipmentManager.php(83): Drupal\commerce_shipping\ShippingMethodStorage->loadMultipleForShipment()
#7 /public_html/modules/contrib/commerce_shipping/src/Plugin/Field/FieldWidget/ShippingRateWidget.php(101): Drupal\commerce_shipping\ShipmentManager->calculateRates()
#8 /public_html/core/lib/Drupal/Core/Field/WidgetBase.php(459): Drupal\commerce_shipping\Plugin\Field\FieldWidget\ShippingRateWidget->formElement()
#9 /public_html/core/lib/Drupal/Core/Field/WidgetBase.php(219): Drupal\Core\Field\WidgetBase->formSingleElement()
#10 /public_html/core/lib/Drupal/Core/Field/WidgetBase.php(120): Drupal\Core\Field\WidgetBase->formMultipleElements()
#11 /public_html/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php(190): Drupal\Core\Field\WidgetBase->form()
#12 /public_html/modules/contrib/commerce_shipping/src/Plugin/Commerce/CheckoutPane/ShippingInformation.php(296): Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm()
#13 /public_html/modules/contrib/commerce/modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowWithPanesBase.php(546): Drupal\commerce_shipping\Plugin\Commerce\CheckoutPane\ShippingInformation->buildPaneForm()
#14 [internal function]: Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow\CheckoutFlowWithPanesBase->buildForm()
#15 /public_html/core/lib/Drupal/Core/Form/FormBuilder.php(536): call_user_func_array()
#16 /public_html/core/lib/Drupal/Core/Form/FormBuilder.php(375): Drupal\Core\Form\FormBuilder->retrieveForm()
#17 /public_html/core/lib/Drupal/Core/Form/FormBuilder.php(633): Drupal\Core\Form\FormBuilder->rebuildForm()
#18 /public_html/core/lib/Drupal/Core/Form/FormBuilder.php(326): Drupal\Core\Form\FormBuilder->processForm()
#19 /public_html/core/lib/Drupal/Core/Form/FormBuilder.php(224): Drupal\Core\Form\FormBuilder->buildForm()
#20 /public_html/modules/contrib/commerce/modules/checkout/src/Controller/CheckoutController.php(143): Drupal\Core\Form\FormBuilder->getForm()
#21 [internal function]: Drupal\commerce_checkout\Controller\CheckoutController->formPage()
#22 /public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#23 /public_html/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#24 /public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#25 /public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#26 /public_html/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#27 /public_html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#28 /public_html/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#29 /public_html/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#30 /public_html/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#31 /public_html/core/modules/page_cache/src/StackMiddleware/PageCache.php(116): Drupal\Core\StackMiddleware\ContentLength->handle()
#32 /public_html/core/modules/page_cache/src/StackMiddleware/PageCache.php(90): Drupal\page_cache\StackMiddleware\PageCache->pass()
#33 /public_html/modules/contrib/advban/src/AdvbanMiddleware.php(57): Drupal\page_cache\StackMiddleware\PageCache->handle()
#34 /public_html/core/modules/ban/src/BanMiddleware.php(50): Drupal\advban\AdvbanMiddleware->handle()
#35 /public_html/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\ban\BanMiddleware->handle()
#36 /public_html/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#37 /public_html/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#38 /public_html/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#39 /public_html/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#40 /public_html/index.php(19): Drupal\Core\DrupalKernel->handle()
#41 {main}

Warning: Trying to access array offset on null in Drupal\commerce_shipping\Plugin\Commerce\Condition\ShipmentWeight->evaluate() (line 138 of /public_html/modules/contrib/commerce_shipping/src/Plugin/Commerce/Condition/ShipmentWeight.php)
#0 /public_html/core/includes/bootstrap.inc(166): _drupal_error_handler_real()
#1 /public_html/modules/contrib/commerce_shipping/src/Plugin/Commerce/Condition/ShipmentWeight.php(138): _drupal_error_handler()
#2 /public_html/modules/contrib/commerce/src/ConditionGroup.php(86): Drupal\commerce_shipping\Plugin\Commerce\Condition\ShipmentWeight->evaluate()
#3 /public_html/modules/contrib/commerce_shipping/src/Entity/ShippingMethod.php(252): Drupal\commerce\ConditionGroup->evaluate()
#4 /public_html/modules/contrib/commerce_shipping/src/ShippingMethodStorage.php(39): Drupal\commerce_shipping\Entity\ShippingMethod->applies()
#5 /public_html/modules/contrib/commerce_shipping/src/ShipmentManager.php(83): Drupal\commerce_shipping\ShippingMethodStorage->loadMultipleForShipment()
#6 /public_html/modules/contrib/commerce_shipping/src/Plugin/Field/FieldWidget/ShippingRateWidget.php(101): Drupal\commerce_shipping\ShipmentManager->calculateRates()
#7 /public_html/core/lib/Drupal/Core/Field/WidgetBase.php(459): Drupal\commerce_shipping\Plugin\Field\FieldWidget\ShippingRateWidget->formElement()
#8 /public_html/core/lib/Drupal/Core/Field/WidgetBase.php(219): Drupal\Core\Field\WidgetBase->formSingleElement()
#9 /public_html/core/lib/Drupal/Core/Field/WidgetBase.php(120): Drupal\Core\Field\WidgetBase->formMultipleElements()
#10 /public_html/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php(190): Drupal\Core\Field\WidgetBase->form()
#11 /public_html/modules/contrib/commerce_shipping/src/Plugin/Commerce/CheckoutPane/ShippingInformation.php(296): Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm()
#12 /public_html/modules/contrib/commerce/modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowWithPanesBase.php(546): Drupal\commerce_shipping\Plugin\Commerce\CheckoutPane\ShippingInformation->buildPaneForm()
#13 [internal function]: Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow\CheckoutFlowWithPanesBase->buildForm()
#14 /public_html/core/lib/Drupal/Core/Form/FormBuilder.php(536): call_user_func_array()
#15 /public_html/core/lib/Drupal/Core/Form/FormBuilder.php(375): Drupal\Core\Form\FormBuilder->retrieveForm()
#16 /public_html/core/lib/Drupal/Core/Form/FormBuilder.php(633): Drupal\Core\Form\FormBuilder->rebuildForm()
#17 /public_html/core/lib/Drupal/Core/Form/FormBuilder.php(326): Drupal\Core\Form\FormBuilder->processForm()
#18 /public_html/core/lib/Drupal/Core/Form/FormBuilder.php(224): Drupal\Core\Form\FormBuilder->buildForm()
#19 /public_html/modules/contrib/commerce/modules/checkout/src/Controller/CheckoutController.php(143): Drupal\Core\Form\FormBuilder->getForm()
#20 [internal function]: Drupal\commerce_checkout\Controller\CheckoutController->formPage()
#21 /public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#22 /public_html/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#23 /public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#24 /public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#25 /public_html/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#26 /public_html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#27 /public_html/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#28 /public_html/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#29 /public_html/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#30 /public_html/core/modules/page_cache/src/StackMiddleware/PageCache.php(116): Drupal\Core\StackMiddleware\ContentLength->handle()
#31 /public_html/core/modules/page_cache/src/StackMiddleware/PageCache.php(90): Drupal\page_cache\StackMiddleware\PageCache->pass()
#32 /public_html/modules/contrib/advban/src/AdvbanMiddleware.php(57): Drupal\page_cache\StackMiddleware\PageCache->handle()
#33 /public_html/core/modules/ban/src/BanMiddleware.php(50): Drupal\advban\AdvbanMiddleware->handle()
#34 /public_html/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\ban\BanMiddleware->handle()
#35 /public_html/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#36 /public_html/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#37 /public_html/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#38 /public_html/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#39 /public_html/index.php(19): Drupal\Core\DrupalKernel->handle()
#40 {main}

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024