Blocks added to all pages produce infinite loop with wrong commercetools credentials

Created on 13 June 2025, 20 days ago

Problem/Motivation

If we add a commercetools block to all pages without excludes, and configure the wrong commercetools credentials, this will lead to an infinite loop with an error like this:

Error: Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of '1000' frames in Drupal\Component\DependencyInjection\Container->hasParameter() (line 337 of core/lib/Drupal/Component/DependencyInjection/Container.php).

Or a memory limit error:
Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 1568768 bytes) in /var/www/html/web/core/lib/Drupal/Core/Database/StatementWrapperIterator.php on line 113

This happens because the function CommercetoolsApiService::executeGraphQlOperation() throws an exception which produces the \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException - that is okay.

But then, Drupal renders the Access Denied page, and starts to render the commercetools block again there (because it is configured to be present on all pages), and the block again throws this exception, leading to the infinite loop.

Steps to reproduce

1. Add a commercetools block to be shown on all pages (for example, Categories block).
2. Configure the wrong commercetools credentials.
3. Open any page with the block and see the infinite loop.

Proposed resolution

Seems we have to add a try-catch constructions to each commercetools block, and render the access denied error (or other exceptions) inline in the block.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇦🇲Armenia murz Yerevan, Armenia

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024