Closed
Description
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
Activity
[-]"Circular reference detected" chen creating a second secret for the prod env[/-][+]"Circular reference detected" when creating a second secret for the prod env[/+]nicolas-grekas commentedon Jun 8, 2020
Can you please provide us with a simple reproducing app? Because I don't reproduce for now. Thanks.
micotodev commentedon Jun 13, 2020
@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 commentedon 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 commentedon 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 commentedon Jun 16, 2020
Duplicate of #37281
Seems as though the exception is thrown and caught, but not in php 7.3.
picks44 commentedon Jun 16, 2020
Using php 7.2 here
jderusse commentedon Jun 18, 2020
because exception thrown in
__tostring
is handled and rethrown by custom handler that prevent reaching thecatch (ParameterCircularReferenceException $e)
inEnvVarProcessor.php
.This issue does not affect >= 7.4 which allows throwing exception in
__tostring
method.picks44 commentedon 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 commentedon Jun 30, 2020
Thanks for the hints about __toString + exceptions. Fixed in #37464.
bug #37464 [ErrorHandler] fix throwing from __toString() (nicolas-gre…
picks44 commentedon Jul 6, 2020
Hi @nicolas-grekas, I see this is merged in SF3.4, what about SF4 and SF5 ?
nicolas-grekas commentedon Jul 6, 2020
It's already merged in all branches, have a look.
bastien70 commentedon Jul 6, 2020
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 commentedon Jul 6, 2020
It's not tagged yet, maybe that's why. You'll need to use 5.1.3 when released.
bastien70 commentedon Jul 6, 2020
Great ! Do you know when the update will be released?