RecaptchaSettingsConfigSubscriber not found

Created on 13 August 2024, about 2 months ago
Updated 20 August 2024, about 1 month ago

Problem/Motivation

Many pages in my dev and staging sites are throwing an error, logging this:

Error: Class "Drupal\recaptcha\EventSubscriber\RecaptchaSettingsConfigSubscriber" not found in Drupal\Component\DependencyInjection\Container->createService() (line 261 of /opt/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php).

Here's the full backtrace:

#0 /opt/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(179): Drupal\Component\DependencyInjection\Container->createService(Array, 'recaptcha.confi...')
#1 /opt/drupal/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(105): Drupal\Component\DependencyInjection\Container->get('recaptcha.confi...')
#2 /opt/drupal/web/core/lib/Drupal/Core/Config/Config.php(230): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Drupal\Core\Config\ConfigCrudEvent), 'config.save')
#3 /opt/drupal/web/modules/custom/miniorange_saml/src/EventSubscriber/InitSubscriber.php(35): Drupal\Core\Config\Config->save()
#4 [internal function]: Drupal\miniorange_saml\EventSubscriber\InitSubscriber->onEvent(Object(Symfony\Component\HttpKernel\Event\RequestEvent), 'kernel.request', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#5 /opt/drupal/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\RequestEvent), 'kernel.request', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#6 /opt/drupal/vendor/symfony/http-kernel/HttpKernel.php(157): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\RequestEvent), 'kernel.request')
#7 /opt/drupal/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#8 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#9 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#10 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#11 /opt/drupal/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#12 /opt/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#13 /opt/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /opt/drupal/web/core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\ban\BanMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /opt/drupal/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /opt/drupal/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#21 {main}

Steps to reproduce

I'm not sure exactly yet. I don't have the problem on my local development Docker containers. There I can load pages, including AJAX webforms that have a reCAPTCHA in it (the recently fixed scenario).

But once I go to dev or staging, I get it on almost every page including admin pages that don't have reCAPTCHAs at all. I can refresh the page and it will load most of the time on the second try.

If I try to load the AJAX webform that has a recaptcha in it, it usually remains stuck in a spinning circle, but a couple of times it did load without showing the recaptcha.

Two differences I can think of between local and dev/staging:

  • miniorange, referenced briefly in the backtrace, is a paid SSO module. Maybe there's some bad interaction with that?
  • Local has more development tools installed, and doesn't have caching by default.

Drupal core 10.3.1

PHP 8.2

Update: I still have the error even after rolling back to version 3.2 and the patch for AJAX, the combination that is currently working on production. So there's some interaction with something else.

Update some more: the problem goes away if I uninstall recaptcha (obviously) as well as if I uninstall miniorange (less obviously). But the problem is still there if I use the same versions of each which were working as recently as earlier today, before I tried the 3.4 update of recaptcha (and then reverted it again).

Some other things I tried:

  • Drupal 10.3.2 update.
  • Reverted the entire database to from before the 3.4 update, then deployed 3.2 again, in case the 3.4 install introduced a problem that the reverting back to 3.2 wasn't fixing.
  • Removed the recaptcha element from the Ajax webform. That maybe resulted in the error showing up less often, but hard to measure.
  • Updated to the latest version of miniorange, a minor bug update.
🐛 Bug report
Status

Closed: cannot reproduce

Version

3.4

Component

reCAPTCHA V2

Created by

🇨🇦Canada ryanrobinson_wlu

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

Comments & Activities

  • Issue created by @ryanrobinson_wlu
  • 🇩🇪Germany Grevil

    Have you cleared all caches using drush cr after updating to the newest version?

    RecaptchaSettingsConfigSubscriber is a new service introduced through 🐛 Ajax support / Use behaviors Needs work . Often enough, the old services.ymls are still cached and newly added services are not taken into account without flushed caches.

    Another case could be, that you have a module installed, which alters your services yml.

  • Status changed to Postponed: needs info about 1 month ago
  • 🇩🇪Germany Anybody Porta Westfalica

    @ryanrobinson_wlu please report this to miniorange so they can take a look. As you're the only one reporting this, I'll set this postponed until this is reproducible without miniorange on vanilla Drupal. Thank you!

    PS: Please leave an update if it was fixed and how / where!

  • 🇨🇦Canada ryanrobinson_wlu

    @Anybody I did report to miniorange. Their first response was "Based on my initial observation, it seems that the event subscribers of both modules are conflicting with each other."

    But @grevil's comment gave me another idea. This error happened around the same time that we were doing some work on shifting to containerized deploys, starting with dev and staging. At one point in there we changed the name of the web Docker service being deployed, but the older ones were still there. There were a couple other minor things we fixed in between those early deployment tests with the old name and the newer tests with the new name, and sometimes we would see the issue in place again and sometimes not. I'm pretty sure what was happening is sometimes I was being served the old one instead of the new one, from before the bugs were fixed.

    So I think there's a pretty good chance that what happened is that the earlier version of recaptcha without RecaptchaSettingsConfigSubscriber was deployed with the old Docker service name. Then the updated version of recaptcha came out and was deployed with the updated name. Sometimes when I was loading the site it served the old one, without RecaptchaSettingsConfigSubscriber but with the database expecting it to exist, creating a fatal error. That would explain why the problem, like the other reappearing bugs, were not entirely consistent, sometimes present and sometimes not. It would also explain why I could only replicate this problem on dev and staging servers, not on my local development environment.

    I'll try to verify that theory and check back in - which might not be immediate since the new deploy process is not quite reliably done yet - but the timeline makes sense and the behaviour mostly makes sense. The only part that doesn't make sense is why uninstalling miniorange seemed to fix it, but maybe that was simply confusing luck that when I tried that I happened to always load the new Docker service without the error.

  • 🇨🇦Canada ryanrobinson_wlu

    Update: I managed a minimal test - not everywhere that it was before, but enough I think - to feel fairly confident in the theory from the previous post. I did not get the error at all on about 20 page loads I tried and filled out the AJAX webform with a recaptcha on it a couple of times, submitting successfully.

  • Status changed to Closed: cannot reproduce about 1 month ago
Production build 0.71.5 2024