Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[FrameworkBundle] secrets:decrypt-to-local shows hard error if invalid secret is found #42038

Closed
@wouterj

Description

@wouterj

Symfony version(s) affected: 4.4

Description
If I wrongly remove a secret (i.e. I don't use secrets:remove and only remove the file and don't update the list), you get a hard error in secrets:decrypt-to-local:

$ symfony console secrets:decrypt-to-local --force -vv

 // 2 secrets found in the vault.

[critical] Error thrown while running command "secrets:decrypt-to-local --force -vv". Message: "Symfony\Component\Console\Formatter\OutputFormatter::escape():
Argument #1 ($text) must be of type string, null given, called in /home/wouter/projects/local/symfony/secrets/vendor/symfony/console/Style/SymfonyStyle.php on
line 476"


In OutputFormatter.php line 41:

  [TypeError]
  Symfony\Component\Console\Formatter\OutputFormatter::escape(): Argument #1 ($text) must be of type string, null given, called in /home/wouter/projects/loc
  al/symfony/secrets/vendor/symfony/console/Style/SymfonyStyle.php on line 476

How to reproduce
I created an app in this state: https://github.com/wouterj/sf-reproducer/tree/secrets-bad-remove

Run the above command and you'll get the hard error.

Possible Solution
Vault::list() reveals all keys using Vault::reveal(). This method resets the last error message each call. The secrets:decrypt-to-local command expects there to be a last error message if the value is null, but this is not the case if a valid secrets is available in the vault after the bad one.

We should either fail in Vault::list() as soon as a bad secret is found, or allow lastMessage to be an array of messages.

Additional context
n/a

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions