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

The service "test.client" has a dependency on a non-existent service "test.client.history". #88

Open
DonCallisto opened this issue Aug 1, 2019 · 19 comments

Comments

@DonCallisto
Copy link
Contributor

DonCallisto commented Aug 1, 2019

Hi,
after upgrading symfony version from 4.2 to 4.3 (actually 4.3.3) I have this error shown when I try to run any behat test.
I think that has something to do with this extension as if I try with a different extension - wich I trying to get rid of; is symfony2extension - everything works fine.
Moreover with symfony 4.2 and this extension, everything is fine.

The error is shown in the title.

@pamil pamil added the Bug label Aug 1, 2019
@pamil
Copy link
Member

pamil commented Aug 1, 2019

Are there any other packages being updated as well? Could you provide a stacktrace (run Behat with -vvv)?

We're using SymfonyExtension v2.0.8 with Symfony v4.3.3 in Sylius builds and it's passing on Travis: https://travis-ci.org/Sylius/Sylius/jobs/566377307

@DonCallisto
Copy link
Contributor Author

DonCallisto commented Aug 1, 2019

I've done a bounce of updates but already in dev (where every test is fine).
In branch I'm working on, this is the only change (removing symfony2extension in favor of yours).

Here's the stack trace.

In CheckExceptionOnInvalidReferenceBehaviorPass.php line 86:

[Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]
The service "test.client" has a dependency on a non-existent service "test.client.history".

Exception trace:
() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:86
Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass->processValue() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php:82
Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass->processValue() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:49
Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass->processValue() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php:91
Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass->processValue() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:49
Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass->processValue() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php:82
Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass->processValue() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:49
Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass->processValue() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php:46
Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass->process() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:40
Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass->process() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php:95
Symfony\Component\DependencyInjection\Compiler\Compiler->compile() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:756
Symfony\Component\DependencyInjection\ContainerBuilder->compile() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:550
Symfony\Component\HttpKernel\Kernel->initializeContainer() at /var/www/nuvola/app/AppKernel.php:227
AppKernel->initializeContainer() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:133
Symfony\Component\HttpKernel\Kernel->boot() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1630
Symfony\Component\DependencyInjection\ContainerBuilder->callMethod() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1168
Symfony\Component\DependencyInjection\ContainerBuilder->createService() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:612
Symfony\Component\DependencyInjection\ContainerBuilder->doGet() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1266
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1214
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1116
Symfony\Component\DependencyInjection\ContainerBuilder->createService() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1268
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1214
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1630
Symfony\Component\DependencyInjection\ContainerBuilder->callMethod() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1168
Symfony\Component\DependencyInjection\ContainerBuilder->createService() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:612
Symfony\Component\DependencyInjection\ContainerBuilder->doGet() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1266
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1214
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1116
Symfony\Component\DependencyInjection\ContainerBuilder->createService() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1268
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1214
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1214
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1116
Symfony\Component\DependencyInjection\ContainerBuilder->createService() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:612
Symfony\Component\DependencyInjection\ContainerBuilder->doGet() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:558
Symfony\Component\DependencyInjection\ContainerBuilder->get() at /var/www/nuvola/vendor/behat/behat/src/Behat/Testwork/Cli/Application.php:161
Behat\Testwork\Cli\Application->createCommand() at /var/www/nuvola/vendor/behat/behat/src/Behat/Testwork/Cli/Application.php:122
Behat\Testwork\Cli\Application->doRun() at /var/www/nuvola/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:149
Symfony\Component\Console\Application->run() at /var/www/nuvola/vendor/behat/behat/bin/behat:34

I've checked Sylius in order to find if you were using the same version but, as long as composer.lock was not included, I could not assume the versions.

@DonCallisto
Copy link
Contributor Author

DonCallisto commented Aug 1, 2019

Debug shows how with old extension (symfony2extension) and symfony 4.3.3, test.client.history is not inlined and so not removed whereas with symfonyextension is.

@DonCallisto
Copy link
Contributor Author

DonCallisto commented Aug 1, 2019

@pamil if I do bin/app debug:container --env=test the container is unable to compile (so is not necessary to reach a behat test).
Does this suggest you something? To me it sounds like it should not be fault of the bundle but as soon as I comment it out from AppKernel everything works like a charm.

Edit: my fault, there's an extension so is perfectly legit for this bundle to be loaded while compiling the container.

@DonCallisto
Copy link
Contributor Author

@pamil my bad, the previous version of symfony was 4.1 not 4.2.
I suspect that this issue is related to AnalyzeServiceReferencesPass

@DonCallisto
Copy link
Contributor Author

DonCallisto commented Aug 21, 2019

A little update for this: I've managed to let it work but still not sure why.
When the issue was there, I use to declare test.client in bind section as follows

services:
  _defaults:
    autowire: true
    autoconfigure: true
    bind:
      $testClient: '@test.client'

As soon as I changed it to an alias like (removing the declaration under bind key)

Symfony\Component\BrowserKit\AbstractBrowser: '@test.client'

everything works. So it must be something in Symfony >= 4.2 or in this extension or in the combination of both that mess up the things.

Any clues?

@siment
Copy link

siment commented Dec 6, 2019

@DonCallisto I think your issue is that you don't have symfony/browser-kit installed. Here is why:

Please have a look at the method

\Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension::load()

specifically the following lines:

        if (!empty($config['test'])) {
            $loader->load('test.xml');

            if (!class_exists(AbstractBrowser::class)) {
                $container->removeDefinition('test.client');
            }
        }

Notice that the definition 'test.client' is removed if it cannot find AbstractBrowser::class. This conditional removal was not present in version 4.2.

The class AbstractBrowser is native to "symfony/browser-kit"

@DonCallisto
Copy link
Contributor Author

@siment I have that bundle installed (and enabled) otherwise I won't be able to do what I've done in #88 (comment)

@siment
Copy link

siment commented Dec 6, 2019

Right... I missed that part. Wish I could help you more. Good luck.

@pamil
Copy link
Member

pamil commented Jan 13, 2020

Does this error still happen with the newest Symfony (4.4.*)?

@DonCallisto
Copy link
Contributor Author

@pamil I will try with Symfony 4.4.* and previous configuration, hopefully, this week end.
Let's keep in touch.

@DonCallisto
Copy link
Contributor Author

@pamil sorry for being late on this. Just updated the project to Symfony4.4.* and the issue is still there.

@cv65kr
Copy link
Contributor

cv65kr commented Mar 16, 2020

I confirmed, still problem with 4.4.

@pamil
Copy link
Member

pamil commented Apr 4, 2020

Build failures on Sylius look connected with this issue: Sylius/Sylius#11029

@DonCallisto
Copy link
Contributor Author

I think that adding AbstractBrowser here will solve the issue.
I've tried to debug the container in my application (using v2.1 of this lib and with the edit suggested) and seems to work.
Moreover AbstractBrowser is what is suggested to replace Client in deprecation notice.

If makes sense to you, I'll open a PR.
Let me know.

@pamil
Copy link
Member

pamil commented Jun 18, 2020

@DonCallisto sounds good, feel free to send a PR. Is there any way we could also test it to avoid regressions in the future?

@DonCallisto
Copy link
Contributor Author

DonCallisto commented Jun 18, 2020

@pamil Maybe check if test.client service is added to the container?
Because if I'm not mistaken here, the fact that test.client is never declared (aliased to be fair), results in test.client to be removed from container and, along with it, also test.client.history.
If we have that alias and one of those implementations is used (injected), test.client.history will never be removed.
WDYT?

@pamil
Copy link
Member

pamil commented Jun 18, 2020

Makes sense! Let's first create a failing test and then add the fix to make sure that's the case. Thanks a lot!

DonCallisto added a commit to DonCallisto/SymfonyExtension that referenced this issue Jun 18, 2020
DonCallisto added a commit to DonCallisto/SymfonyExtension that referenced this issue Jun 18, 2020
DonCallisto added a commit to DonCallisto/SymfonyExtension that referenced this issue Jun 18, 2020
@DonCallisto
Copy link
Contributor Author

@pamil take a look at #129
LGTY?

DonCallisto added a commit to DonCallisto/SymfonyExtension that referenced this issue Jun 18, 2020
DonCallisto added a commit to DonCallisto/SymfonyExtension that referenced this issue Jun 18, 2020
DonCallisto added a commit to DonCallisto/SymfonyExtension that referenced this issue Jun 18, 2020
DonCallisto added a commit to DonCallisto/SymfonyExtension that referenced this issue Jun 18, 2020
DonCallisto added a commit to DonCallisto/SymfonyExtension that referenced this issue Jun 18, 2020
DonCallisto added a commit to DonCallisto/SymfonyExtension that referenced this issue Jun 18, 2020
DonCallisto added a commit to DonCallisto/SymfonyExtension that referenced this issue Jun 18, 2020
DonCallisto added a commit to DonCallisto/SymfonyExtension that referenced this issue Jun 18, 2020
DonCallisto added a commit to DonCallisto/SymfonyExtension that referenced this issue Jun 19, 2020
DonCallisto added a commit to DonCallisto/SymfonyExtension that referenced this issue Dec 14, 2021
Yozhef added a commit that referenced this issue Dec 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants