Skip to content

[DependencyInjection] ParameterCircularReferenceException when creating secrets #37281

@jderusse

Description

@jderusse
Member

Symfony version(s) affected: 5.1

Description
When creating secrets with command, a ParameterCircularReferenceException is triggered.

How to reproduce

symfony new project --full
bin/console secret:set --env=prod TEST
bin/console secret:set --env=prod TEST2

Additional context

The EnvVarProcessor contains code to rpevend it, but I don't understand why it fails. Maybe related to the LazyString and exception triggered in __toString.
stack trace show that exception is triggered throught EnvVarProcessor line 153.
Line this line is wrap in try/catch block

#0 /data/oss/project/vendor/symfony/string/LazyString.php(41): 
...
#6 /data/oss/project/vendor/symfony/dependency-injection/EnvVarProcessor.php(153): 

try {
$i = 0;
$ended = true;
$count = $loaders instanceof \Countable ? $loaders->count() : 0;
foreach ($loaders as $loader) {
if (\count($this->loadedVars) > $i++) {
continue;
}
$this->loadedVars[] = $vars = $loader->loadEnvVars();
if (false !== $env = $vars[$name] ?? false) {
$ended = false;
break;
}
}
if ($ended || $count === $i) {
$loaders = $this->loaders;
}
} catch (ParameterCircularReferenceException $e) {
// skip loaders that need an env var that is not defined
} finally {

/cc @nicolas-grekas

Activity

simonberger

simonberger commented on Jun 14, 2020

@simonberger
Contributor

I failed to reproduce this. Exception is thrown and caught.
I'm currently on a windows machine with PHP 7.4 in case this matters.

jderusse

jderusse commented on Jun 15, 2020

@jderusse
MemberAuthor

currently using php 7.3

picks44

picks44 commented on Jun 16, 2020

@picks44

I have the issue and using php 7.2

weaverryan

weaverryan commented on Jun 18, 2020

@weaverryan
Member

I personally failed to reproduce this, but a user on SymfonyCasts definitely hit it - https://symfonycasts.com/screencast/symfony5-upgrade/secrets-vault-setup#comment-4957289406

So I'd say that there IS a legit issue here. The circular reference in that case was for SYMFONY_DECRYPTION_SECRET which the user never defined anywhere. I assume @jderusse that the ParameterCircularReferenceException was also for SYMFONY_DECRYPTION_SECRET in your case?

simonberger

simonberger commented on Jun 18, 2020

@simonberger
Contributor

This issue should be closed as a duplicate of #37142. Discussion and Information are splitting.

jderusse

jderusse commented on Jun 18, 2020

@jderusse
MemberAuthor

@weaverryan php 7.4 I guess

closing in favor of #37142

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

        @weaverryan@jderusse@xabbuh@picks44@simonberger

        Issue actions

          [DependencyInjection] ParameterCircularReferenceException when creating secrets · Issue #37281 · symfony/symfony