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

"Circular reference detected" when creating a second secret for the prod env #37142

Closed
picks44 opened this issue Jun 8, 2020 · 14 comments
Closed

Comments

@picks44
Copy link

picks44 commented Jun 8, 2020

Symfony version(s) affected: 5.1.0

Description
Got a Circular reference error when adding a second secret for the prod env. No problems in dev or staging env...

Fatal error: Symfony\Component\DependencyInjection\Exception\ParameterCircularRe
ferenceException: Circular reference detected for parameter "env(base64:default:
:SYMFONY_DECRYPTION_SECRET)" ("env(base64:default::SYMFONY_DECRYPTION_SECRET)" >
 "env(default::SYMFONY_DECRYPTION_SECRET)" > "env(SYMFONY_DECRYPTION_SECRET)" >
"env(base64:default::SYMFONY_DECRYPTION_SECRET)"). in C:\laragon\www\DESmdc\vend
or\symfony\dependency-injection\Container.php:389
Stack trace:
#0 C:\laragon\www\DESmdc\vendor\symfony\string\LazyString.php(41): Symfony\Compo
nent\DependencyInjection\Container->getEnv('base64:default:...')
#1 C:\laragon\www\DESmdc\vendor\symfony\string\LazyString.php(103): Symfony\Comp
onent\String\LazyString::Symfony\Component\String\{closure}()
#2 C:\laragon\www\DESmdc\vendor\symfony\framework-bundle\Secrets\SodiumVault.php
(183): Symfony\Component\String\LazyString->__toString()
#3 C:\laragon\www\DESmdc\vendor\symfony\framework-bundle\Secrets\SodiumVault.php
(114): Symfony\Bundle\FrameworkBundle\Secrets\SodiumVault->loadKeys()
 in C:\laragon\www\DESmdc\vendor\symfony\string\LazyString.php on line 116

How to reproduce

  • Migrated from 4.4 to 5.0 then 5.1.
  • Created secrets in dev and staging env without any problem
  • Removed them from the .env file
  • Started created secrets for prod, first one OK
  • Second one (tried with different keys) failed with the above error
@picks44 picks44 added the Bug label Jun 8, 2020
@picks44 picks44 changed the title "Circular reference detected" chen creating a second secret for the prod env "Circular reference detected" when creating a second secret for the prod env Jun 8, 2020
@nicolas-grekas
Copy link
Member

Can you please provide us with a simple reproducing app? Because I don't reproduce for now. Thanks.

@micotodev
Copy link

@nicolas-grekas Able to reproduce using the --full symfony project, but not the standard.
symfony new project --full
bin/console secret:set --env=prod TEST
bin/console secret:set --env=prod TEST2

@micotodev
Copy link

micotodev commented Jun 14, 2020

Narrowed the bug down to when the symfony/monolog-bundle is added as a dependency. The bug appears related to php < 7.4.

@picks44
Copy link
Author

picks44 commented Jun 15, 2020

I posted about thsi on Symfony's Slack and other users also experiment this, so it doesn't seem to be an isolated problem.

@micotodev
Copy link

micotodev commented Jun 16, 2020

Duplicate of #37281

Seems as though the exception is thrown and caught, but not in php 7.3.

@picks44
Copy link
Author

picks44 commented Jun 16, 2020

Using php 7.2 here

@jderusse
Copy link
Member

because exception thrown in __tostring is handled and rethrown by custom handler that prevent reaching the catch (ParameterCircularReferenceException $e) in EnvVarProcessor.php.

This issue does not affect >= 7.4 which allows throwing exception in __tostring method.

@picks44
Copy link
Author

picks44 commented Jun 30, 2020

Hi there, any plans to fix this in a near future? I guess there still are a lot of people using php 7.2 like myself!

@nicolas-grekas
Copy link
Member

Thanks for the hints about __toString + exceptions. Fixed in #37464.

nicolas-grekas added a commit that referenced this issue Jun 30, 2020
…kas)

This PR was merged into the 3.4 branch.

Discussion
----------

[ErrorHandler] fix throwing from __toString()

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #37142
| License       | MIT
| Doc PR        | -

Commits
-------

aeb4637 [ErrorHandler] fix throwing from __toString()
@picks44
Copy link
Author

picks44 commented Jul 6, 2020

Hi @nicolas-grekas, I see this is merged in SF3.4, what about SF4 and SF5 ?

@nicolas-grekas
Copy link
Member

It's already merged in all branches, have a look.

@bastien70
Copy link

Hello @nicolas-grekas , I'm on Symfony 5.1, with PHP 7.3, my recipes are up to date, and yet the problem persists, with the same error code

@nicolas-grekas
Copy link
Member

It's not tagged yet, maybe that's why. You'll need to use 5.1.3 when released.

@bastien70
Copy link

Great ! Do you know when the update will be released?

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

8 participants