CRITICAL: Uncaught PHP Exception Twig error

Your software
My Mautic version is: 5.0.3
My PHP version is: 8.1
My Database type and version is: Recent

Your problem
My problem is:
Recently upgraded from v4 to v5.0.3. Now having a problem creating a Focus item, (also viewing some Reports). Halfway through building one, Mautic craps out and I get the error monster. The rest of Mautic is still functional, mostly.

These errors are showing in the log:
[2024-04-04T13:52:22.574719+00:00] mautic.CRITICAL: Uncaught PHP Exception Twig\Error\RuntimeError: “Variable “fieldSettings” does not exist.” at /home/username/domain.com/mautic/app/bundles/FormBundle/Resources/views/Builder/form.html.twig line 50 {“exception”:“[object] (Twig\Error\RuntimeError(code: 0): Variable "fieldSettings" does not exist. at /home/username/domain.com/mautic/app/bundles/FormBundle/Resources/views/Builder/form.html.twig:50)”} {“hostname”:“iad1-shared-e1-06”,“pid”:413170}

[2024-04-04T14:28:23.150217+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 /home/username/domain.com/mautic/var/tmp/twig/ef/ef6787421501ecc99158046e98ee62ae.php on line 124”).” at /home/username/domain.com/mautic/app/bundles/ReportBundle/Resources/views/Graph/Table.html.twig line 37 {“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 /home/username/domain.com/mautic/var/tmp/twig/ef/ef6787421501ecc99158046e98ee62ae.php on line 124"). at /home/username/domain.com/mautic/app/bundles/ReportBundle/Resources/views/Graph/Table.html.twig:37)\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 /home/username/domain.com/mautic/var/tmp/twig/ef/ef6787421501ecc99158046e98ee62ae.php on line 124 at /home/username/domain.com/mautic/app/bundles/CoreBundle/Twig/Extension/AssetExtension.php:166)”} {“hostname”:“iad1-shared-e1-06”,“pid”:447319}

Steps I have tried to fix the problem:
Researched Twig, tried changing themes, but got the same error.

Here’s the Report error log (choosing Leads and Points):

[2024-04-04T14:28:23.150217+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 /home/username/domain.com/mautic/var/tmp/twig/ef/ef6787421501ecc99158046e98ee62ae.php on line 124”).” at /home/username/domain.com/mautic/app/bundles/ReportBundle/Resources/views/Graph/Table.html.twig line 37 {“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 /home/username/domain.com/mautic/var/tmp/twig/ef/ef6787421501ecc99158046e98ee62ae.php on line 124"). at /home/username/domain.com/mautic/app/bundles/ReportBundle/Resources/views/Graph/Table.html.twig:37)\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 /home/username/domain.com/mautic/var/tmp/twig/ef/ef6787421501ecc99158046e98ee62ae.php on line 124 at /home/username/domain.com/mautic/app/bundles/CoreBundle/Twig/Extension/AssetExtension.php:166)”} {“hostname”:“iad1-shared-e1-06”,“pid”:447319}

Did you do a “clear:cache”? Also in installs across major releases and certain situations I needed to do a separate “mautic:assets:generate” via the console on the command line.

Yep, I did. Also, did m:a:g. But is there any harm in doing m:a:g again?

Okay, ran m:a:g again and cleared cache, no dice.

Noticed that node_modules directory was somehow missing (wtf?) even though npm and nvm were both installed. Reinstalled them, then regenerated assets, and cleared cache, but still getting the same Twig error. Can’t view Lead/Points or Visit Published Pages reports.

Upgraded to 5.0.4 without issue. Same Twig error. Super weird.

I’m also having the same error/exception when trying to view the default report “Downloads of all Assets” on a fresh installation. It is worth mention that the report has not been modified.

Installation Details:

  • Docker image: mautic/mautic:5-apache
  • Mautic version: 5.0.4
  • PHP version: 8.1.28
  • Database: 11.3.2-MariaDB (pdo_mysql)

Steps to Reproduce:

  1. On a fresh install, add an asset
    – Upload a local file (I tried with both .png and .jpg)
    – Do not alter/edit anything else and click on “Save & Close”
    – Copy the download URL
  2. Generate a lead by opening the download URL of the newly created asset in a web browser (I used an incognito window on Brave browser)
  3. Open the report “Downloads of all Assets
    – A 500 Internal Server Error is thrown.

PHP Error Log:

[2024-04-25T02:14:31.432973+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 /var/www/html/var/tmp/twig/82/8239dceed72df500b32440cab9d9a10c.php on line 125”).” at /var/www/html/docroot/app/bundles/ReportBundle/Resources/views/Graph/Table.html.twig line 37 {“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 /var/www/html/var/tmp/twig/82/8239dceed72df500b32440cab9d9a10c.php on line 125"). at /var/www/html/docroot/app/bundles/ReportBundle/Resources/views/Graph/Table.html.twig:37)\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 /var/www/html/var/tmp/twig/82/8239dceed72df500b32440cab9d9a10c.php on line 125 at /var/www/html/docroot/app/bundles/CoreBundle/Twig/Extension/AssetExtension.php:166)”} {“hostname”:“mautic-web-ix-chart-84db4cdd65-zgbfj”,“pid”:23}