# Twig Template to Handle Null Values

**URL:** <https://forum.mautic.org/t/twig-template-to-handle-null-values/36495>\
**Category:** Mautic 6 Install/Upgrade Support\
**Created:** [September 8, 2025, 6:38pm UTC](https://forum.mautic.org/t/twig-template-to-handle-null-values/36495 "2025-09-08T18:38:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mtcusr](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mtcusr/32/13386_2.png) [@mtcusr](https://forum.mautic.org/u/mtcusr)\
**Post date:** [September 8, 2025, 6:38pm UTC](https://forum.mautic.org/t/twig-template-to-handle-null-values/36495/1 "2025-09-08T18:38:50Z")

</div>

Installation Details:

- Mautic Version: 6.0.4

- Apache: 2.4.6

- PHP version: 8.2.29

- Database: 10.11.14 (mariadb)

Checking the mautic\_prod log there are the following, which searching the forum seems to be related to among other the error I have with the All Emails report:

`[2025-09-08T16:44:19.440400+00:00] mautic.CRITICAL: Uncaught PHP Exception Twig\Error\RuntimeError: “An exception has been thrown during the rendering of a template (“Mautic\CoreBundle\Twig\Extension\AssetExtension::makeLinks(): Argument #1 ($text) must be of type string, null given, called in /html/var/tmp/twig/2d/2df6af1e0790f8f9fe30ed8d65a3f626.php on line 132”).” at /html/app/bundles/ReportBundle/Resources/views/Graph/Table.html.twig line 38 {“exception”:“[object] (Twig\Error\RuntimeError(code: 0): An exception has been thrown during the rendering of a template ("Mautic\CoreBundle\Twig\Extension\AssetExtension::makeLinks(): Argument #1 ($text) must be of type string, null given, called in /html/var/tmp/twig/2d/2df6af1e0790f8f9fe30ed8d65a3f626.php on line 132"). at /html/app/bundles/ReportBundle/Resources/views/Graph/Table.html.twig:38)\n[previous exception] [object] (TypeError(code: 0): Mautic\CoreBundle\Twig\Extension\AssetExtension::makeLinks(): Argument #1 ($text) must be of type string, null given, called in /html/var/tmp/twig/2d/2df6af1e0790f8f9fe30ed8d65a3f626.php on line 132 at /html/app/bundles/CoreBundle/Twig/Extension/AssetExtension.php:176)”} {“hostname”:“apch-njrdmbe”,“pid”:1238154}`

And saw also some suggestions for patch to search for makeLinks, find the call (e.g., {{ makeLinks(some\_variable) }} or {{ assetExtension.makeLinks(some\_variable) }}) and change it to handle null:

```auto
{{ makeLinks(some_variable | default('') | default(null)) }}

```

Has this been addressed already?

---

<div class="post-metadata">

**Author:** ![mtcusr](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mtcusr/32/13386_2.png) [@mtcusr](https://forum.mautic.org/u/mtcusr)\
**Post date:** [September 9, 2025, 10:53am UTC](https://forum.mautic.org/t/twig-template-to-handle-null-values/36495/2 "2025-09-09T10:53:44Z")

</div>

So let’s get this temporary fixed then - The current line 38 in /html/app/bundles/ReportBundle/Resources/views/Graph/Table.html.twig looks like this:

`{{ assetMakeLinks(cell) }}`

which I changed to:

`{{ cell is not empty ? assetMakeLinks(cell) : ‘’ }}`

This ensures that cell exists and is not null before calling _assetMakeLinks(cell)_, and if cell is null, it returns an empty string to prevent a crash. And once again the _All Emails_ report works again.

Hopefully this little patch can be of help for someone else.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/1X/43c63600fe51440378769136903f1fa2a9a34102.png) [@system](https://forum.mautic.org/u/system)\
**Post date:** [September 10, 2025, 10:54pm UTC](https://forum.mautic.org/t/twig-template-to-handle-null-values/36495/3 "2025-09-10T22:54:22Z")

</div>

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.
