Skip to content

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

Closed
@picks44

Description

@picks44

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

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[/+] on Jun 8, 2020
nicolas-grekas

nicolas-grekas commented on Jun 8, 2020

@nicolas-grekas
Member

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

micotodev

micotodev commented on Jun 13, 2020

@micotodev

@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

micotodev commented on Jun 14, 2020

@micotodev

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

picks44

picks44 commented on Jun 15, 2020

@picks44
Author

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

micotodev commented on Jun 16, 2020

@micotodev

Duplicate of #37281

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

picks44

picks44 commented on Jun 16, 2020

@picks44
Author

Using php 7.2 here

jderusse

jderusse commented on Jun 18, 2020

@jderusse
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

picks44 commented on Jun 30, 2020

@picks44
Author

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

nicolas-grekas commented on Jun 30, 2020

@nicolas-grekas
Member

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

added a commit that references this issue on Jun 30, 2020

bug #37464 [ErrorHandler] fix throwing from __toString() (nicolas-gre…

034be44
picks44

picks44 commented on Jul 6, 2020

@picks44
Author

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

nicolas-grekas

nicolas-grekas commented on Jul 6, 2020

@nicolas-grekas
Member

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

bastien70

bastien70 commented on Jul 6, 2020

@bastien70

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

nicolas-grekas commented on Jul 6, 2020

@nicolas-grekas
Member

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

bastien70

bastien70 commented on Jul 6, 2020

@bastien70

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @nicolas-grekas@jderusse@micotodev@xabbuh@yceruto

        Issue actions

          "Circular reference detected" when creating a second secret for the prod env · Issue #37142 · symfony/symfony