HTML::escape() WSOD or "profile cannot be referenced" when manually entering a shipment that popups "Confirm your shipping address"

Created on 4 February 2025, about 1 month ago

As a non-uid admin:

1. Head to admin/commerce/orders/add.
2. Choose any "Existing customer" then "Create".
3. "Add new order item" that requires shipping.
4. "Save" the order.
5. Click the "Shipments" tab then "Add shipment".
6. For the "Shipping information", use "United States", "613 E. Industrial Drive", "Chelsea", "Michigan", "48118" then hit "Save".
7. Choose the "Shipment item" and "Recalculate shipping". Choose a shipping method.
8. Click "Save".
9. The "Confirm your shipping address" popup will appear saying the "Recommended address is "613 E Industrial Dr, Chelsea, MI 48118-1536 US". Click "Use recommended".
10. You might get a WSOD (in 3.0.0 final) saying "TypeError: Drupal\Component\Utility\Html::escape(): Argument #1 ($text) must be of type string, null given, called in web/core/lib/Drupal/Component/Render/FormattableMarkup.php on line 238 in Drupal\Component\Utility\Html::escape() (line 431 of core/lib/Drupal/Component/Utility/Html.php)."
11. Alternatively (in 3.0.0 beta 2), the form might submit but fail validation, and the only error is "This entity (profile: 56) cannot be referenced."
12. Repeat these steps until you get to the "Confirm your shipping address" popup again. Instead of "Use recommended", choose "Use as entered". Either you'll get a WSOD with the same warning, or the shipment will save successfully.

Full stack:

#0 web/core/lib/Drupal/Component/Render/FormattableMarkup.php(256): Drupal\Component\Utility\Html::escape()
#1 web/core/lib/Drupal/Component/Render/FormattableMarkup.php(205): Drupal\Component\Render\FormattableMarkup::placeholderEscape()
#2 web/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php(195): Drupal\Component\Render\FormattableMarkup::placeholderFormat()
#3 web/core/lib/Drupal/Component/Utility/ToStringTrait.php(15): Drupal\Core\StringTranslation\TranslatableMarkup->render()
#4 web/core/lib/Drupal/Core/Messenger/Messenger.php(54): Drupal\Core\StringTranslation\TranslatableMarkup->__toString()
#5 web/modules/contrib/commerce_shipping/src/Form/ShipmentForm.php(344): Drupal\Core\Messenger\Messenger->addMessage()
#6 [internal function]: Drupal\commerce_shipping\Form\ShipmentForm->save()
#7 web/core/lib/Drupal/Core/Form/FormSubmitter.php(105): call_user_func_array()
#8 web/core/lib/Drupal/Core/Form/FormSubmitter.php(43): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers()
#9 web/core/lib/Drupal/Core/Form/FormBuilder.php(589): Drupal\Core\Form\FormSubmitter->doSubmitForm()
#10 web/core/lib/Drupal/Core/Form/FormBuilder.php(321): Drupal\Core\Form\FormBuilder->processForm()
#11 web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
#12 web/core/modules/layout_builder/src/Controller/LayoutBuilderHtmlEntityFormController.php(39): Drupal\Core\Controller\FormController->getContentResult()
#13 [internal function]: Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult()
#14 web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#15 web/core/lib/Drupal/Core/Render/Renderer.php(593): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#16 web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#17 web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#18 vendor/symfony/http-kernel/HttpKernel.php(183): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#19 vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#20 web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#21 web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#22 web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#23 web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
#24 web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
#25 web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#26 web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#27 web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#28 web/core/lib/Drupal/Core/DrupalKernel.php(709): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#29 web/index.php(19): Drupal\Core\DrupalKernel->handle()
#30 {main}

πŸ› Bug report
Status

Active

Version

2.0

Component

User interface

Created by

πŸ‡ΊπŸ‡ΈUnited States morbus iff

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

Comments & Activities

  • Issue created by @morbus iff
  • πŸ‡ΊπŸ‡ΈUnited States morbus iff

    rszrama is suggesting this has something to do with Avatax.

  • πŸ‡ΊπŸ‡ΈUnited States morbus iff
  • πŸ‡ΊπŸ‡ΈUnited States morbus iff

    If you head to commerce/config/avatax and uncheck "Validate addresses in checkout", the test scenario above works with no issue.

  • πŸ‡ΊπŸ‡ΈUnited States morbus iff
  • πŸ‡ΊπŸ‡ΈUnited States rszrama

    Confirming I can reproduce the error. Interestingly enough, it actually works fine if you edit a shipment that already exists. That leads me to believe we could maybe make this work, which would be great - however, it should at least be tied to a different setting. We can't have something that says "validate addresses in checkout" also randomly apply to the admin UI. 🀣

  • πŸ‡ΊπŸ‡ΈUnited States rszrama

    Oh, wow. I just realized in testing today that the specific error here is related to the fact that I was attempting (and I assume you were attempting) to create a shipment against a draft order that does not yet have an order number. The Shipping module creates a message with an order number placeholder that cannot by NULL, apparently, though I assume this worked before as casted to an empty string. Not sure.

    $this->messenger()->addMessage($this->t('Saved shipment for order @order.', ['@order' => $order->getOrderNumber()]));
    

    In any case, I don't see why shipping doesn't just use the order label. I've changed that in Commerce Shipping here: πŸ› Use the order label when saving a shipment instead of order number Fixed

    Since this wasn't actually a bug in AvaTax, I'm reverting this to a feature request specifically to differentiate validating addresses on checkout vs. the backend.

  • πŸ‡ΊπŸ‡ΈUnited States rszrama

    Committed an update that separates the settings. Turns out it works just fine on the admin form once the label issue is resolved. πŸ˜„

    • rszrama β†’ committed 0b0d4422 on 8.x-1.x
      Issue #3504334 by rszrama: Separate the setting for address validation...
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024