Skip to content

[Dependency Injection] - Invalid env(p-redis-osb) name: only "word" characters are allowed. #34864

Closed
@ybenhssaien

Description

@ybenhssaien

Description
This subject is already discussed in #33806, this is a limitation when working on some cloud services like CloudFoundry to get a service credentials, all services have a name format like (p-redis-osb), the simple way to fetch the target variable by env() is doing something like : %env(key:host:key:credentials:key:p-redis-osb:json:VCAP_SERVICES), thanks to json and key processors.

VCAP_SERVICES respect the naming convention, but getting a key from json doesn't respect the /^(?:\w*+:)*+\w++$/ and generate an exception here

Suggestion : Accepting a - make since if the value is not the root in env() syntax !

Modify regex here to do :

-if (!preg_match('/^(?:\w*+:)*+\w++$/', $env)) {
+if (!preg_match('/^(?:[\w-]*+:)*+\w++$/', $env)) {

Regex test : https://regex101.com/r/fhdJys/2

Example

# services.yaml
 redis_session.host: '%env(key:host:key:credentials:key:p-redis-osb:json:VCAP_SERVICES)%'

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