Skip to content

Env var processor examples for arrays don't work #50341

Closed
@uncaught

Description

@uncaught

Symfony version(s) affected

symfony/dependency-injection 6.2.10

Description

I'm trying to configure trusted_headers/trusted_hosts via environment variables, but neither the json nor the csv example work.

All I get is:

Invalid type for path "framework.trusted_hosts.0". Expected one of "bool", "int", "float", "string", but got "array".

I've seen #28599 and #27683, but I can't find a solution in them.

Am I missing some component or is the documentation wrong?

How to reproduce

Use one of these in your framework.yaml:

parameters:
    env(TRUSTED_HOSTS): '["10.0.0.1", "10.0.0.2"]'
framework:
    trusted_hosts: '%env(json:TRUSTED_HOSTS)%'
parameters:
    env(TRUSTED_HOSTS): "10.0.0.1,10.0.0.2"
framework:
   trusted_hosts: '%env(csv:TRUSTED_HOSTS)%'

Possible Solution

No response

Additional Context

I've also switch to symfony/flex, so I might miss a component, but the installed EnvVarProcessor seems to include the json/csv handling.

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