Drupal 10.2: TypeError: Drupal\Core\StringTranslation\ByteSizeMarkup::create(): Argument #1 ($size) must be of type int|float, null given

Created on 9 January 2024, 9 months ago

Problem/Motivation

On a Drupal 10.2 site, an s3fs_cors field widget that doesn't have a max_filesize set will throw an HTTP 500 error. This is due to Drupal 10.2 replacing the 'file_validate_size' validator with 'FileSizeLimit'.

Steps to reproduce

Install Drupal 10.2 and this module. Configure an s3fs_cors field widget for either the file or image type and do not set a max filesize. Go to a form that will display the field widget. The request that should render the image will instead throw an uncaught exception and the request will fail. See comments for a full stack trace.

Proposed resolution

When setting the max filesize on the form element try to use the 'FileSizeLimit' validator information too.

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

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

Comments & Activities

  • Issue created by @david.muffley
  • Traceback:

    #0 /my/web/root/web/core/modules/file/file.module(1240): Drupal\Core\StringTranslation\ByteSizeMarkup::create()
    #1 [internal function]: template_preprocess_file_upload_help()
    #2 /my/web/root/web/core/lib/Drupal/Core/Theme/ThemeManager.php(261): call_user_func_array()
    #3 /my/web/root/web/core/lib/Drupal/Core/Render/Renderer.php(480): Drupal\Core\Theme\ThemeManager->render()
    #4 /my/web/root/web/core/lib/Drupal/Core/Render/Renderer.php(240): Drupal\Core\Render\Renderer->doRender()
    #5 /my/web/root/web/core/lib/Drupal/Core/Render/Renderer.php(165): Drupal\Core\Render\Renderer->render()
    #6 /my/web/root/web/core/lib/Drupal/Core/Render/Renderer.php(627): Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}()
    #7 /my/web/root/web/core/lib/Drupal/Core/Render/Renderer.php(166): Drupal\Core\Render\Renderer->executeInRenderContext()
    #8 /my/web/root/web/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php(130): Drupal\Core\Render\Renderer->renderPlain()
    #9 /my/web/root/web/core/lib/Drupal/Core/Field/WidgetBase.php(117): Drupal\image\Plugin\Field\FieldWidget\ImageWidget->formMultipleElements()
    #10 /my/web/root/web/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php(186): Drupal\Core\Field\WidgetBase->form()
    #11 /my/web/root/web/modules/contrib/inline_entity_form/src/Form/EntityInlineForm.php(174): Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm()
    #12 /my/web/root/web/modules/contrib/inline_entity_form/src/Element/InlineEntityForm.php(149): Drupal\inline_entity_form\Form\EntityInlineForm->entityForm()
    #13 [internal function]: Drupal\inline_entity_form\Element\InlineEntityForm::processEntityForm()
    #14 /my/web/root/web/core/lib/Drupal/Core/Form/FormBuilder.php(1013): call_user_func_array()
    #15 /my/web/root/web/core/lib/Drupal/Core/Form/FormBuilder.php(1076): Drupal\Core\Form\FormBuilder->doBuildForm()
    ... truncated 
  • Attaching a patch that fixes my issue and doesn't disrupt Drupal 10.1 users.

  • Issue was unassigned.
  • Status changed to Needs review 9 months ago
Production build 0.71.5 2024