Skip to content

[DependencyInjection] Service names containing underscores not working after upgrading to 6.4.0 #52815

@paullallier

Description

@paullallier

Symfony version(s) affected

6.4.0

Description

Sorry - I'm not sure if this is a bug or just a misconfiguration by me.

Upgrading from 6.3.x to 6.4.0, and autowiring Redis is suddenly throwing an error.

How to reproduce

I have this, which works in 6.3.9:

<?php

declare(strict_types=1);

namespace App\MessageHandler;

use App\Message\ClearUserAccessTokens;
use Redis;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;

#[AsMessageHandler]
readonly class ClearUserAccessTokensHandler
{
    public function __construct(protected Redis $redis_valid_token)
    {
    }

When I upgrade to 6.4.0, I get this error:

!!  In DefinitionErrorExceptionPass.php line 51:
!!                                                                                 
!!    Cannot autowire service "App\MessageHandler\ClearUserAccessTokensHandler":   
!!    argument "$redis_valid_token" of method "__construct()" references class "R  
!!    edis" but no such service exists. Did you mean to target one of "redis_vali  
!!    d_token", "redis_refresh" instead?                          

Might this be a bug, or just a config issue on my project (nothing changes apart from upgrading Symfony and a few other packages not related to Redis)

In case it's relevant, I'm using snc/redis-bundle to manage the services, with phpredis:

services:
    Redis $redis_valid_token: '@snc_redis.valid_token'
    Redis $redis_refresh: '@snc_redis.refresh'


snc_redis:
    clients:
        refresh:
            type: phpredis
            alias: refresh
            dsn: "%env(REDIS_URL_REFRESH)%"
        valid_token:
            type: phpredis
            alias: valid_token
            dsn: "%env(REDIS_URL_VALIDTOKEN)%"

If I rollback the upgrade, it starts working again.

Possible Solution

No response

Additional Context

No response

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