After upgrading from Magento 2.4.6-p12 to 2.4.6-p13, our S3 URL generation is producing malformed URLs with /./ appended to the path. This is breaking our file URLs and causing 404 errors.
The getObjectUrl method in AWS S3 client is generating URLs like:
https://bucket.s3.amazonaws.com/./
Instead of the expected:
https://bucket.s3.amazonaws.com/
Code Example :
Here’s the relevant code (from AWS SDK):
public function getObjectUrl($bucket, $key)
{
$command = $this->getCommand('GetObject', [
'Bucket' => $bucket,
'Key' => $key
]);
return (string) Awsserialize($command)->getUri();
}
Debug Output
When I log the URI components, I get:
json
{
"scheme": "https",
"host": "bucket.s3.amazonaws.com",
"path": "/./",
"full_uri": "https://bucket.s3.amazonaws.com/./"
}
What I’ve Tried Temporary fix – String replacement:
$url = (string) Awsserialize($command)->getUri();
return str_replace('/./', '/', $url);
Checked AWS SDK versions – Both pre and post-upgrade use AWS SDK 3.x, but there might be minor version differences.
Verified the issue is in URI serialization – The path component itself is /./ which suggests a URI normalization issue.
But I am looking at which library or code cause the issue as i have compared the old and new vendor file of the module Magento_AwsS3 and also check vendor/aws/aws-sdk-php/src/S3/S3Client.php function getObjectUrl the code is same so what the library causing the issue want to know and avoid temporary fix.