Skip to content

[Bug]: SF filesystem bundle - s3 client is private #2355

@jenky

Description

@jenky

What happened?

The aws_s3 client_service_id doesn't work because client_service_id needs to be public in order to be retrieved via ->get by the $container.

A possible solution I can think of is to create a service locator that contains all async_aws.client.* services and inject it into AsyncAwsS3FilesystemFactory. The constructor can keep the ContainerInterface $container type hint. However, the async_aws.client.* services are created without a tag, so there's no way to build the locator automatically.


So I tried creating it manually and injecting it into .flow.filesystem.factory.aws_s3 but it also doesn't work because all filesystem factories are private

    async_aws.client_locator:
        class: Symfony\Component\DependencyInjection\ServiceLocator
        arguments:
            -
                async_aws.client.s3: '@async_aws.client.s3'

    .flow.filesystem.factory.aws_s3:
        class: Flow\Bridge\Symfony\FilesystemBundle\Filesystem\Factory\AsyncAwsS3FilesystemFactory
        arguments:
            - '@async_aws.client_locator'

The workaround that ended up working for me is to create a public alias for async_aws.client.s3 and use the alias in client_service_id

    async_aws.client.s3.public:
        alias: async_aws.client.s3
        public: true
aws-s3:
    type: aws_s3
    bucket: '%aws.s3.bucket%'
    client_service_id: async_aws.client.s3.public

Not a great trick, since I have to manually create a public alias for each S3 client.

How to reproduce?

async_aws:
    config:
        region: '...'
        accessKeyId: '...'
        accessKeySecret: '...'
        endpoint: '...'

    # All installed clients are automatically autowired. Use this section to customize clients
    clients:
        s3:
            config:
                region: '...'

flow_filesystem:
    fstabs:
        default:
            filesystems:
                file:
                    type: file
                aws-s3:
                    type: aws_s3
                    bucket: '%aws.s3.bucket%'
                    client_service_id: async_aws.client.s3

Playground snippet

No response

Data required to reproduce bug locally

No response

Version

What version of Flow are you using? (e.g., 0.37.*)

Relevant error output

[ERROR] The "async_aws.client.s3" service or alias has been removed or inlined when the container was compiled. You    
         should either make it public, or stop using the container directly and use dependency injection instead.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions