Drupal 11: Circular reference detected for service "authentication_subscriber"

Created on 10 July 2024, 4 months ago

Problem/Motivation

Trying to get a brand new Drupal 11 site set up. Need to test Simple Oauth on this new site. Installing Consumers/Simple OAuth crashes site with a Circular reference detected for service "authentication_subscriber" error

Steps to reproduce

Install Drupal 11.0.0-beta-1.
Install consumers and simple_oauth via drupal_git and the repositories block of composer.json (gets around missing D11 patch for drupal/consumers:

    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        },
        {
            "type": "package",
            "package": {
                "name": "drupal_git/consumers",
                "version": "dev-1.x",
                "type": "drupal-module",
                "source": {
                    "url": "https://git.drupalcode.org/project/consumers.git",
                    "type": "git",
                    "reference": "8.x-1.x"
                }
            }
        },
        {
            "type": "package",
            "package": {
                "name": "drupal_git/simple_oauth",
                "version": "dev-6.0.x",
                "type": "drupal-module",
                "source": {
                    "url": "https://git.drupalcode.org/project/simple_oauth.git",
                    "type": "git",
                    "reference": "6.0.x"
                }
            }
        }
    ],

Then later...

    "extra": {
        "patches": {
            "drupal_git/consumers": {
                "3429497 - Automated Drupal 11 compatibility fixes for consumers": "https://www.drupal.org/files/issues/2024-06-02/consumers.1.x-dev.rector.patch"
            }
        },

compoer require drupal_git/consumers drupal_git/simple_oauth
drush en simple_oauth

Full error as follows:

appserver_1 | [Wed Jul 10 21:37:34.987976 2024] [php:notice] [pid 2377] [client 172.240.2.2:44596] Symfony\\Component\\DependencyInjection\\Exception\\ServiceCircularReferenceException: Circular reference detected for service "authentication_subscriber", path: "authentication_subscriber -> authentication -> authentication_collector -> simple_oauth.authentication.simple_oauth -> simple_oauth.server.resource_server.factory -> simple_oauth.repositories.access_token". in /app/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 147 #0 /app/web/core/lib/Drupal/Component/DependencyInjection/Container.php(454): Drupal\\Component\\DependencyInjection\\Container->get('authentication_...', 1)\n#1 /app/vendor/symfony/event-dispatcher/EventDispatcher.php(243): Drupal\\Component\\DependencyInjection\\Container->Drupal\\Component\\DependencyInjection\\{closure}()\n#2 /app/vendor/symfony/event-dispatcher/EventDispatcher.php(206): Symfony\\Component\\EventDispatcher\\EventDispatcher::Symfony\\Component\\EventDispatcher\\{closure}(Object(Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent), 'kernel.exceptio...', Object(Symfony\\Component\\EventDispatcher\\EventDispatcher))\n#3 /app/vendor/symfony/event-dispatcher/EventDispatcher.php(56): Symfony\\Component\\EventDispatcher\\EventDispatcher->callListeners(Array, 'kernel.exceptio...', Object(Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent))\n#4 /app/vendor/symfony/http-kernel/HttpKernel.php(241): Symfony\\Component\\EventDispatcher\\EventDispatcher->dispatch(Object(Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent), 'kernel.exceptio...')\n#5 /app/vendor/symfony/http-kernel/HttpKernel.php(91): Symfony\\Component\\HttpKernel\\HttpKernel->handleThrowable(Object(Error), Object(Symfony\\Component\\HttpFoundation\\Request), 1)\n#6 /app/web/modules/contrib/simple_oauth/src/HttpMiddleware/BasicAuthSwap.php(54): Symfony\\Component\\HttpKernel\\HttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#7 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Drupal\\simple_oauth\\HttpMiddleware\\BasicAuthSwap->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#8 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\\Core\\StackMiddleware\\Session->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#9 /app/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\\Core\\StackMiddleware\\KernelPreHandle->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#10 /app/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\\Core\\StackMiddleware\\ContentLength->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#11 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\\big_pipe\\StackMiddleware\\ContentLength->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#12 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\\page_cache\\StackMiddleware\\PageCache->pass(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#13 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\\page_cache\\StackMiddleware\\PageCache->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#14 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#15 /app/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\\Core\\StackMiddleware\\NegotiationMiddleware->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#16 /app/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\\Core\\StackMiddleware\\AjaxPageState->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#17 /app/web/core/lib/Drupal/Core/DrupalKernel.php(705): Drupal\\Core\\StackMiddleware\\StackedHttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#18 /app/web/index.php(19): Drupal\\Core\\DrupalKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request))\n#19 {main}

This might be user error - investigating...

🐛 Bug report
Status

Closed: works as designed

Version

6.0

Component

Code

Created by

🇨🇦Canada TrevorBradley

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

Comments & Activities

  • Issue created by @TrevorBradley
  • 🇨🇦Canada TrevorBradley

    It's definitely not a circular reference - in Container:get() the authentication_subscriber service never moves out of the loading state.

    It's an error during loading the loading the container: Interface "League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface" not found

    Yup, that library is missing from the vendor directory... This is almost certainly related to broken requirements because of my weird drupal_git install.

    Let me figure out how to install simple_oauth correctly on Drupal 11, document it here, then close this ticket.

  • 🇨🇦Canada TrevorBradley

    Yup, the problem with a drupal_git install to get around patching is that it ignores ALL requirements... Not just drupal/consumers but also everything in simple_oauth's compiser.json:

        "require": {
            "league/oauth2-server": "^8.5 || ^9.0",
            "steverhoades/oauth2-openid-connect-server": "^2.6",
            "drupal/consumers": "^1.17",
            "php": ">=8.1"
        },

    Simple short term fix:
    composer require league/oauth2-server:^8.5 steverhoades/oauth2-openid-connect-server:^2.6

    and all is well.

    Learning moment for me, hopefully useful to some poor person doing a google search later.

  • Status changed to Closed: works as designed 4 months ago
  • 🇨🇦Canada TrevorBradley

    ....and if you're using lando like me: lando rebuild lando's APC caches the contents of the vendor directory in a weird way as referenced here: https://www.drupal.org/forum/support/post-installation/2018-01-13/fatal-...

Production build 0.71.5 2024