Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twig errors not always useful #17962

Open
2 tasks
cconard96 opened this issue Sep 30, 2024 · 0 comments
Open
2 tasks

Twig errors not always useful #17962

cconard96 opened this issue Sep 30, 2024 · 0 comments

Comments

@cconard96
Copy link
Contributor

cconard96 commented Sep 30, 2024

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

Version

main, probably 10.0.X too

Bug description

Twig errors are not always helpful

Example:

[2024-09-30 13:44:37] glpiphplog.CRITICAL:   *** Twig Error (Twig\Error\RuntimeError): "An exception has been thrown during the rendering of a template ("htmlspecialchars(): Argument #1 ($string) must be of type string, array given")." in template "/var/www/html/fix95/templates/pages/admin/assetdefinition/fields_display.html.twig" at line 88
  Backtrace :
  ...tes/8b/8b8ad4bd6e753ec7db12a070d5e1a8e4.php:151 Twig\Template->yieldBlock()
  vendor/twig/twig/src/Template.php:393              __TwigTemplate_88674ac2a0c746d1b3caa437ef8972e4->doDisplay()
  ...ates/43/4395f33b9b7d76d1d1a3273bc9abe2b1.php:58 Twig\Template->yield()
  vendor/twig/twig/src/Template.php:393              __TwigTemplate_9565bf0a3d697575d7e47c47cf5d1c18->doDisplay()
  vendor/twig/twig/src/Template.php:349              Twig\Template->yield()
  vendor/twig/twig/src/TemplateWrapper.php:42        Twig\Template->display()
  src/Glpi/Application/View/TemplateRenderer.php:185 Twig\TemplateWrapper->display()
  src/Glpi/Asset/AssetDefinition.php:199             Glpi\Application\View\TemplateRenderer->display()
  src/Glpi/Asset/AssetDefinition.php:152             Glpi\Asset\AssetDefinition->showFieldsForm()
  src/CommonGLPI.php:665                             Glpi\Asset\AssetDefinition::displayTabContentForItem()
  ajax/common.tabs.php:110                           CommonGLPI::displayStandardTab()
  ...Glpi/Controller/LegacyFileLoadController.php:58 require()
  vendor/symfony/http-kernel/HttpKernel.php:101      Glpi\Controller\LegacyFileLoadController->Glpi\Controller\{closure}()
  ...ymfony/http-foundation/StreamedResponse.php:106 Symfony\Component\HttpKernel\HttpKernel::Symfony\Component\HttpKernel\{closure}()
  vendor/symfony/http-foundation/Response.php:423    Symfony\Component\HttpFoundation\StreamedResponse->sendContent()
  public/index.php:58                                Symfony\Component\HttpFoundation\Response->send()

The referred line in the template has no such call to htmlspecialchars. Instead, it is a macro call for fields.dropdownArrayField.
I don't know why the Twig error backtrace ends here, but the information in $error->getPrevious() is far more useful and isn't logged anywhere.

The previous error correctly shows it is a TypeError in Dropdown line 2422 due to an incorrectly formatted elements parameter.

Relevant log output

No response

Page URL

No response

Steps To reproduce

No response

Your GLPI setup information

No response

Anything else?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant