RecaptchaSettingsConfigSubscriber not found

Created on 13 August 2024, 8 months 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 plugin. 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

🐛 Bug report
Status

Active

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 Fixed . 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 8 months 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 8 months ago
  • Status changed to Active 4 months ago
  • 🇦🇺Australia dpi Perth, Australia

    Finding a project I'm on is encountering this.

    Yes, its true a cache clear should resolve it. However procedure when modifying services.yml involves adding a new empty post_update function, which triggers a cache clear.

    You can see core does this (moreso when you're not on a point-zero release, like 11.0), e.g user_post_update_sort_permissions

    Would be good to add a new empty postupdate function, it obviously wouldnt be detrimental to existing sites.

    Re-opening issue, as its a pretty easy thing to implement.

Production build 0.71.5 2024