Skip to content

aws-s3 fileExists method result is not reliable #1622

@caspla

Description

@caspla

Bug Report

Q A
Flysystem Version 3.12.0
Adapter Name flysystem-aws-s3-v3
Adapter version 3.10.3

Summary

Calling $storage->fileExists() returns true if the underlying S3 server responds with an status code "Access Denied".
I get this status code from my minIO server even if the file does not exist. I do not know if this also happends in other S3 implementations.

The thing is that fileExists method calls S3Client::doesObjectExists which has the problematic behavior.
There is a issue aws/aws-sdk-php#2342 and also a fix for aws-sdk-php which is already merged: aws/aws-sdk-php#2424

They introduced a new method doesObjectExistsV2, which should handle the described situatuin properly.
Currently flysystem still uses the regular doesObjectExists method.

How to reproduce

Call $storage->fileExists('path/to/file/that/not/exists') and watch the returned value.

Tested with latest minIO from minio/minio docker image
minio version RELEASE.2023-01-02T09-40-09Z (commit-id=1cd8e1d8b633550e18a108a0f042941afab6e923)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions