Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeleteObjects needs MD5 param #3068

Closed
1 task
asterissco opened this issue Jan 28, 2025 · 6 comments
Closed
1 task

DeleteObjects needs MD5 param #3068

asterissco opened this issue Jan 28, 2025 · 6 comments
Assignees
Labels
breaking-change Issue requires a breaking change to remediate. bug This issue is a bug.

Comments

@asterissco
Copy link

asterissco commented Jan 28, 2025

Describe the bug

aws-version:

aws/aws-crt-php                    v1.2.7    AWS Common Runtime for PHP
aws/aws-sdk-php                    3.339.0   AWS SDK for PHP - Use Amazon Web Services in your PHP project

php-version: PHP 8.3.1 (cli)

DeleteObjects method has stopped working, return this issue


  Error executing "DeleteObjects" on "http://192.168.22.50:9000/default?delete"; AWS HTTP error: Client error: `POST http://192.168.22.50:9000/default?delete` resulted in a `400 Bad Request` response:
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>MissingContentMD5</Code><Message>Missing required header for this re (truncated...)
 MissingContentMD5 (client): Missing required header for this request: Content-Md5. - <?xml version="1.0" encoding="UTF-8"?>
<Error><Code>MissingContentMD5</Code><Message>Missing required header for this request: Content-Md5.</Message><BucketName>default</BucketName><Resource>/default</Resource><RequestId>181EE3A2C13907B9</RequestId><
HostId>dd9025bab4ad464b049177c95eb6ebf374d3b3fd1af9251148b658df7ac2e3e8</HostId></Error>

  at vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php:196
    192▕         $parts['request'] = $request;
    193▕         $parts['connection_error'] = !empty($err['connection_error']);
    194▕         $parts['transfer_stats'] = $stats;
    195▕ 
  ➜ 196▕         return new $this->exceptionClass(
    197▕             sprintf(
    198▕                 'Error executing "%s" on "%s"; %s',
    199▕                 $command->getName(),
    200▕                 $request->getUri(),

      +20 vendor frames 
  21  app/Console/Commands/Escombros.php:71
      Aws\AwsClient::__call()

      +12 vendor frames 
  34  artisan:35

The DeleteObject method works correctly.

According to S3 documentation this parameter is not needed in this method doc

$result = $client->deleteObjects([
    'Bucket' => '<string>', // REQUIRED
    'BypassGovernanceRetention' => true || false,
    'ChecksumAlgorithm' => 'CRC32|CRC32C|SHA1|SHA256|CRC64NVME',
    'Delete' => [ // REQUIRED
        'Objects' => [ // REQUIRED
            [
                'ETag' => '<string>',
                'Key' => '<string>', // REQUIRED
                'LastModifiedTime' => <integer || string || DateTime>,
                'Size' => <integer>,
                'VersionId' => '<string>',
            ],
            // ...
        ],
        'Quiet' => true || false,
    ],
    'ExpectedBucketOwner' => '<string>',
    'MFA' => '<string>',
    'RequestPayer' => 'requester',
]);

I'm not sure if the parameter refers to the md5 of the message or the files.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

Fail

aws/aws-sdk-php 3.339.0 AWS SDK for PHP - Use Amazon Web Services in your PHP project

Works

aws/aws-sdk-php 3.296.1 AWS SDK for PHP - Use Amazon Web Services in your PHP project

Current Behavior

qrms@pre:/opt/qualitas/common/backend$ php artisan qaisc:escombros

-> Entering step init, name 'idempotency_auto_fill'
---------------------------------------------------

  command was set to array(3) {
    ["instance"]=>
    string(32) "000000000000061f0000000000000000"
    ["name"]=>
    string(13) "DeleteObjects"
    ["params"]=>
    array(5) {
      ["Bucket"]=>
      string(7) "default"
      ["Delete"]=>
      array(1) {
        ["Objects"]=>
        array(1) {
          [0]=>
          array(1) {
            ["Key"]=>
            string(44) "20250125/02/7d26e317b3f22e38b4278e7431c20907"
          }
        }
      }
      ["ChecksumAlgorithm"]=>
      string(6) "SHA256"
      ["@http"]=>
      array(3) {
        ["connect_timeout"]=>
        NULL
        ["timeout"]=>
        NULL
        ["debug"]=>
        resource(901) of type (stream)
      }
      ["@context"]=>
      array(0) {
      }
    }
  }
  
  request was set to array(0) {
  }
  


-> Entering step init, name 's3.ssec'
-------------------------------------

  no changes


-> Entering step init, name 's3.source_file'
--------------------------------------------

  no changes


-> Entering step init, name 's3.save_as'
----------------------------------------

  no changes


-> Entering step init, name 's3.location'
-----------------------------------------

  no changes


-> Entering step init, name 's3.auto_encode'
--------------------------------------------

  no changes


-> Entering step init, name 's3.head_object'
--------------------------------------------

  no changes


-> Entering step validate, name 'validation'
--------------------------------------------

  no changes


-> Entering step validate, name 'input_validation_middleware'
-------------------------------------------------------------

  no changes


-> Entering step build, name 'auth-selection'
---------------------------------------------

  [email protected]_version was set to v4


-> Entering step build, name 'endpoint-resolution'
--------------------------------------------------

  [email protected]_version changed from v4 to s3v4
  [email protected]_service was set to s3
  [email protected]_region was set to Region1


-> Entering step build, name 'builder'
--------------------------------------

  request.instance was set to 00000000000007930000000000000000
  request.method was set to POST
  request.headers was set to array(4) {
    ["X-Amz-Security-Token"]=>
    string(7) "[TOKEN]"
    ["Host"]=>
    array(1) {
      [0]=>
      string(18) "192.168.22.50:9000"
    }
    ["Content-Type"]=>
    array(1) {
      [0]=>
      string(15) "application/xml"
    }
    ["x-amz-sdk-checksum-algorithm"]=>
    array(1) {
      [0]=>
      string(6) "SHA256"
    }
  }
  
  request.body was set to <?xml version="1.0" encoding="UTF-8"?>
  <Delete xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Object><Key>20250125/02/7d26e317b3f22e38b4278e7431c20907</Key></Object></Delete>
  
  request.scheme was set to http
  request.port was set to 9000
  request.path was set to /default
  request.query was set to delete


-> Entering step build, name 's3.check_empty_path_with_query'
-------------------------------------------------------------

  no changes


-> Entering step build, name 'ApiCallMonitoringMiddleware'
----------------------------------------------------------

  no changes


-> Entering step build, name ''
-------------------------------

  request.instance changed from 00000000000007930000000000000000 to 000000000000087b0000000000000000
  request.headers.X-Amz-User-Agent was set to array(1) {
    [0]=>
    string(0) ""
  }
  


-> Entering step build, name 'endpoint_parameter'
-------------------------------------------------

  no changes


-> Entering step build, name 'request-compression'
--------------------------------------------------

  no changes


-> Entering step build, name 'recursion-detection'
--------------------------------------------------

  no changes


-> Entering step build, name 's3.checksum'
------------------------------------------

  request.instance changed from 000000000000087b0000000000000000 to 00000000000008870000000000000000
  request.headers.x-amz-checksum-sha256 was set to array(1) {
    [0]=>
    string(44) "IfqaE6tK6dLP6CU9t1uh/6sNrtB3TuefxjhSzj222f8="
  }
  


-> Entering step build, name 's3.content_type'
----------------------------------------------

  no changes


-> Entering step build, name 's3.bucket_endpoint_arn'
-----------------------------------------------------

  no changes


-> Entering step sign, name 'StreamRequestPayloadMiddleware'
------------------------------------------------------------

  no changes


-> Entering step sign, name 'invocation-id'
-------------------------------------------

  request.instance changed from 00000000000008870000000000000000 to 000000000000087d0000000000000000
  request.headers.aws-sdk-invocation-id was set to array(1) {
    [0]=>
    string(32) "f7b10bea407e82273a644643dcefcebe"
  }
  


-> Entering step sign, name 'retry'
-----------------------------------

  request.instance changed from 000000000000087d0000000000000000 to 00000000000008840000000000000000
  request.headers.aws-sdk-retry was set to array(1) {
    [0]=>
    string(3) "0/0"
  }
  


-> Entering step sign, name 'signer'
------------------------------------

  request.instance changed from 00000000000008840000000000000000 to 000000000000084b0000000000000000
  request.headers.x-amz-content-sha256 was set to array(1) {
    [0]=>
    string(64) "21fa9a13ab4ae9d2cfe8253db75ba1ffab0daed0774ee79fc63852ce3db6d9ff"
  }
  
  request.headers.X-Amz-Date was set to array(1) {
    [0]=>
    string(16) "20250128T152113Z"
  }
  
  request.headers.Authorization was set to array(1) {
    [0]=>
    string(270) "AWS4-HMAC-SHA256 Credential=administrador/20250128/Region1/s3/aws4_request, SignedHeaders=host;x-amz-checksum-sha256;x-amz-content-sha256;x-amz-date;x-amz-sdk-checksum-algorithm;x-amz-user-agent, Signature=[SIGNATURE]
  }
  


-> Entering step sign, name 'user-agent'
----------------------------------------

  request.instance changed from 000000000000084b0000000000000000 to 000000000000084c0000000000000000
  request.headers.User-Agent was set to array(1) {
    [0]=>
    string(78) "aws-sdk-php/3.339.0 ua/2.1 OS/Linux#5.4.0-169-generic lang/php#8.3.1 m/P,Y,e,N"
  }
  


-> Entering step sign, name 's3.expires_parsing'
------------------------------------------------

  no changes


-> Entering step sign, name 's3.put_object_url'
-----------------------------------------------

  no changes


-> Entering step sign, name 's3.permanent_redirect'
---------------------------------------------------

  no changes


-> Entering step attempt, name 'ApiCallAttemptMonitoringMiddleware'
-------------------------------------------------------------------

  no changes

*   Trying 192.168.22.50:9000...
* TCP_NODELAY set
* Connected to 192.168.22.50 (192.168.22.50) port 9000 (#0)
> POST /default?delete HTTP/1.1
Host: 192.168.22.50:9000
Content-Type: application/xml
x-amz-sdk-checksum-algorithm: SHA256
X-Amz-User-Agent:
x-amz-checksum-sha256: IfqaE6tK6dLP6CU9t1uh/6sNrtB3TuefxjhSzj222f8=
aws-sdk-invocation-id: f7b10bea407e82273a644643dcefcebe
aws-sdk-retry: 0/0
x-amz-content-sha256: 21fa9a13ab4ae9d2cfe8253db75ba1ffab0daed0774ee79fc63852ce3db6d9ff
X-Amz-Date: 20250128T152113Z
Authorization: AWS4-HMAC-SHA256 Credential=administrador/20250128/Region1/s3/aws4_request, SignedHeaders=host;x-amz-checksum-sha256;x-amz-content-sha256;x-amz-date;x-amz-sdk-checksum-algorithm;x-amz-user-agent, Signature=[SIGNATURE]
User-Agent: aws-sdk-php/3.339.0 ua/2.1 OS/Linux#5.4.0-169-generic lang/php#8.3.1 m/P,Y,e,N GuzzleHttp/7
Content-Length: 177

* upload completely sent off: 177 out of 177 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 400 Bad Request
< Accept-Ranges: bytes
< Content-Length: 338
< Content-Type: application/xml
< Server: MinIO
< Strict-Transport-Security: max-age=31536000; includeSubDomains
< Vary: Origin
< Vary: Accept-Encoding
< X-Amz-Id-2: dd9025bab4ad464b049177c95eb6ebf374d3b3fd1af9251148b658df7ac2e3e8
< X-Amz-Request-Id: 181EE46F572C9D03
< X-Content-Type-Options: nosniff
< X-Xss-Protection: 1; mode=block
< Date: Tue, 28 Jan 2025 15:21:13 GMT
< 
* Connection #0 to host 192.168.22.50 left intact

<- Leaving step attempt, name 'ApiCallAttemptMonitoringMiddleware'
------------------------------------------------------------------

  error was set to array(13) {
    ["instance"]=>
    string(32) "00000000000008830000000000000000"
    ["class"]=>
    string(28) "Aws\S3\Exception\S3Exception"
    ["message"]=>
    string(759) "Error executing "DeleteObjects" on "http://192.168.22.50:9000/default?delete"; AWS HTTP error: Client error: `POST http://192.168.22.50:9000/default?delete` resulted in a `400 Bad Request` response:
  <?xml version="1.0" encoding="UTF-8"?>
  <Error><Code>MissingContentMD5</Code><Message>Missing required header for this re (truncated...)
   MissingContentMD5 (client): Missing required header for this request: Content-Md5. - <?xml version="1.0" encoding="UTF-8"?>
  <Error><Code>MissingContentMD5</Code><Message>Missing required header for this request: Content-Md5.</Message><BucketName>default</BucketName><Resource>/default</Resource><RequestId>181EE46F572C9D03</RequestId><HostId>dd9025bab4ad464b049177c95eb6ebf374d3b3fd1af9251148b658df7ac2e3e8</HostId></Error>"
    ["file"]=>
    string(78) "/opt/qualitas/common/backend/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php"
    ["line"]=>
    int(196)
    ["trace"]=>
    string(3934) "#0 /opt/qualitas/common/backend/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php(97): Aws\WrappedHttpHandler->parseError()
  #1 /opt/qualitas/common/backend/vendor/guzzlehttp/promises/src/Promise.php(209): Aws\WrappedHttpHandler->Aws\{closure}()
  #2 /opt/qualitas/common/backend/vendor/guzzlehttp/promises/src/Promise.php(174): GuzzleHttp\Promise\Promise::callHandler()
  #3 /opt/qualitas/common/backend/vendor/guzzlehttp/promises/src/RejectedPromise.php(49): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
  #4 /opt/qualitas/common/backend/vendor/guzzlehttp/promises/src/TaskQueue.php(52): GuzzleHttp\Promise\RejectedPromise::GuzzleHttp\Promise\{closure}()
  #5 /opt/qualitas/common/backend/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(167): GuzzleHttp\Promise\TaskQueue->run()
  #6 /opt/qualitas/common/backend/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(206): GuzzleHttp\Handler\CurlMultiHandler->tick()
  #7 /opt/qualitas/common/backend/vendor/guzzlehttp/promises/src/Promise.php(251): GuzzleHttp\Handler\CurlMultiHandler->execute()
  #8 /opt/qualitas/common/backend/vendor/guzzlehttp/promises/src/Promise.php(227): GuzzleHttp\Promise\Promise->invokeWaitFn()
  #9 /opt/qualitas/common/backend/vendor/guzzlehttp/promises/src/Promise.php(272): GuzzleHttp\Promise\Promise->waitIfPending()
  #10 /opt/qualitas/common/backend/vendor/guzzlehttp/promises/src/Promise.php(229): GuzzleHttp\Promise\Promise->invokeWaitList()
  #11 /opt/qualitas/common/backend/vendor/guzzlehttp/promises/src/Promise.php(272): GuzzleHttp\Promise\Promise->waitIfPending()
  #12 /opt/qualitas/common/backend/vendor/guzzlehttp/promises/src/Promise.php(229): GuzzleHttp\Promise\Promise->invokeWaitList()
  #13 /opt/qualitas/common/backend/vendor/guzzlehttp/promises/src/Promise.php(69): GuzzleHttp\Promise\Promise->waitIfPending()
  #14 /opt/qualitas/common/backend/vendor/aws/aws-sdk-php/src/AwsClientTrait.php(58): GuzzleHttp\Promise\Promise->wait()
  #15 /opt/qualitas/common/backend/vendor/aws/aws-sdk-php/src/AwsClientTrait.php(86): Aws\AwsClient->execute()
  #16 /opt/qualitas/common/backend/app/Console/Commands/Escombros.php(71): Aws\AwsClient->__call()
  #17 /opt/qualitas/common/backend/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): App\Console\Commands\Escombros->handle()
  #18 /opt/qualitas/common/backend/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
  #19 /opt/qualitas/common/backend/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure()
  #20 /opt/qualitas/common/backend/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\Container\BoundMethod::callBoundMethod()
  #21 /opt/qualitas/common/backend/vendor/laravel/framework/src/Illuminate/Container/Container.php(662): Illuminate\Container\BoundMethod::call()
  #22 /opt/qualitas/common/backend/vendor/laravel/framework/src/Illuminate/Console/Command.php(211): Illuminate\Container\Container->call()
  #23 /opt/qualitas/common/backend/vendor/symfony/console/Command/Command.php(326): Illuminate\Console\Command->execute()
  #24 /opt/qualitas/common/backend/vendor/laravel/framework/src/Illuminate/Console/Command.php(180): Symfony\Component\Console\Command\Command->run()
  #25 /opt/qualitas/common/backend/vendor/symfony/console/Application.php(1096): Illuminate\Console\Command->run()
  #26 /opt/qualitas/common/backend/vendor/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand()
  #27 /opt/qualitas/common/backend/vendor/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun()
  #28 /opt/qualitas/common/backend/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(201): Symfony\Component\Console\Application->run()
  #29 /opt/qualitas/common/backend/artisan(35): Illuminate\Foundation\Console\Kernel->handle()
  #30 {main}"
    ["type"]=>
    string(6) "client"
    ["code"]=>
    string(17) "MissingContentMD5"
    ["requestId"]=>
    string(16) "181EE46F572C9D03"
    ["statusCode"]=>
    int(400)
    ["result"]=>
    NULL
    ["request"]=>
    array(8) {
      ["instance"]=>
      string(32) "000000000000084c0000000000000000"
      ["method"]=>
      string(4) "POST"
      ["headers"]=>
      array(12) {
        ["X-Amz-Security-Token"]=>
        string(7) "[TOKEN]"
        ["Host"]=>
        array(1) {
          [0]=>
          string(18) "192.168.22.50:9000"
        }
        ["Content-Type"]=>
        array(1) {
          [0]=>
          string(15) "application/xml"
        }
        ["x-amz-sdk-checksum-algorithm"]=>
        array(1) {
          [0]=>
          string(6) "SHA256"
        }
        ["X-Amz-User-Agent"]=>
        array(1) {
          [0]=>
          string(0) ""
        }
        ["x-amz-checksum-sha256"]=>
        array(1) {
          [0]=>
          string(44) "IfqaE6tK6dLP6CU9t1uh/6sNrtB3TuefxjhSzj222f8="
        }
        ["aws-sdk-invocation-id"]=>
        array(1) {
          [0]=>
          string(32) "f7b10bea407e82273a644643dcefcebe"
        }
        ["aws-sdk-retry"]=>
        array(1) {
          [0]=>
          string(3) "0/0"
        }
        ["x-amz-content-sha256"]=>
        array(1) {
          [0]=>
          string(64) "21fa9a13ab4ae9d2cfe8253db75ba1ffab0daed0774ee79fc63852ce3db6d9ff"
        }
        ["X-Amz-Date"]=>
        array(1) {
          [0]=>
          string(16) "20250128T152113Z"
        }
        ["Authorization"]=>
        array(1) {
          [0]=>
          string(270) "AWS4-HMAC-SHA256 Credential=administrador/20250128/Region1/s3/aws4_request, SignedHeaders=host;x-amz-checksum-sha256;x-amz-content-sha256;x-amz-date;x-amz-sdk-checksum-algorithm;x-amz-user-agent, Signature=[SIGNATURE]
        }
        ["User-Agent"]=>
        array(1) {
          [0]=>
          string(78) "aws-sdk-php/3.339.0 ua/2.1 OS/Linux#5.4.0-169-generic lang/php#8.3.1 m/P,Y,e,N"
        }
      }
      ["body"]=>
      string(177) "<?xml version="1.0" encoding="UTF-8"?>
  <Delete xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Object><Key>20250125/02/7d26e317b3f22e38b4278e7431c20907</Key></Object></Delete>
  "
      ["scheme"]=>
      string(4) "http"
      ["port"]=>
      int(9000)
      ["path"]=>
      string(8) "/default"
      ["query"]=>
      string(6) "delete"
    }
    ["response"]=>
    array(4) {
      ["instance"]=>
      string(32) "00000000000008890000000000000000"
      ["statusCode"]=>
      int(400)
      ["headers"]=>
      array(12) {
        ["X-Amz-Security-Token"]=>
        string(7) "[TOKEN]"
        ["Accept-Ranges"]=>
        array(1) {
          [0]=>
          string(5) "bytes"
        }
        ["Content-Length"]=>
        array(1) {
          [0]=>
          string(3) "338"
        }
        ["Content-Type"]=>
        array(1) {
          [0]=>
          string(15) "application/xml"
        }
        ["Server"]=>
        array(1) {
          [0]=>
          string(5) "MinIO"
        }
        ["Strict-Transport-Security"]=>
        array(1) {
          [0]=>
          string(35) "max-age=31536000; includeSubDomains"
        }
        ["Vary"]=>
        array(2) {
          [0]=>
          string(6) "Origin"
          [1]=>
          string(15) "Accept-Encoding"
        }
        ["X-Amz-Id-2"]=>
        array(1) {
          [0]=>
          string(64) "dd9025bab4ad464b049177c95eb6ebf374d3b3fd1af9251148b658df7ac2e3e8"
        }
        ["X-Amz-Request-Id"]=>
        array(1) {
          [0]=>
          string(16) "181EE46F572C9D03"
        }
        ["X-Content-Type-Options"]=>
        array(1) {
          [0]=>
          string(7) "nosniff"
        }
        ["X-Xss-Protection"]=>
        array(1) {
          [0]=>
          string(13) "1; mode=block"
        }
        ["Date"]=>
        array(1) {
          [0]=>
          string(29) "Tue, 28 Jan 2025 15:21:13 GMT"
        }
      }
      ["body"]=>
      string(338) "<?xml version="1.0" encoding="UTF-8"?>
  <Error><Code>MissingContentMD5</Code><Message>Missing required header for this request: Content-Md5.</Message><BucketName>default</BucketName><Resource>/default</Resource><RequestId>181EE46F572C9D03</RequestId><HostId>dd9025bab4ad464b049177c95eb6ebf374d3b3fd1af9251148b658df7ac2e3e8</HostId></Error>"
    }
  }
  
  Inclusive step time: 0.0056898593902588


<- Leaving step sign, name 's3.permanent_redirect'
--------------------------------------------------

  no changes
  Inclusive step time: 0.0057778358459473


<- Leaving step sign, name 's3.put_object_url'
----------------------------------------------

  no changes
  Inclusive step time: 0.0058450698852539


<- Leaving step sign, name 's3.expires_parsing'
-----------------------------------------------

  no changes
  Inclusive step time: 0.0059170722961426


<- Leaving step sign, name 'user-agent'
---------------------------------------

  no changes
  Inclusive step time: 0.0060272216796875


<- Leaving step sign, name 'signer'
-----------------------------------

  no changes
  Inclusive step time: 0.0065209865570068


<- Leaving step sign, name 'retry'
----------------------------------

  no changes
  Inclusive step time: 0.0078480243682861


<- Leaving step sign, name 'invocation-id'
------------------------------------------

  no changes
  Inclusive step time: 0.007943868637085


<- Leaving step sign, name 'StreamRequestPayloadMiddleware'
-----------------------------------------------------------

  no changes
  Inclusive step time: 0.0080101490020752


<- Leaving step build, name 's3.bucket_endpoint_arn'
----------------------------------------------------

  no changes
  Inclusive step time: 0.0080769062042236


<- Leaving step build, name 's3.content_type'
---------------------------------------------

  no changes
  Inclusive step time: 0.0082659721374512


<- Leaving step build, name 's3.checksum'
-----------------------------------------

  no changes
  Inclusive step time: 0.0083630084991455


<- Leaving step build, name 'recursion-detection'
-------------------------------------------------

  no changes
  Inclusive step time: 0.0085179805755615


<- Leaving step build, name 'request-compression'
-------------------------------------------------

  no changes
  Inclusive step time: 0.0085840225219727


<- Leaving step build, name 'endpoint_parameter'
------------------------------------------------

  no changes
  Inclusive step time: 0.0086419582366943


<- Leaving step build, name ''
------------------------------

  no changes
  Inclusive step time: 0.0087349414825439


<- Leaving step build, name 'ApiCallMonitoringMiddleware'
---------------------------------------------------------

  no changes
  Inclusive step time: 0.0088238716125488


<- Leaving step build, name 's3.check_empty_path_with_query'
------------------------------------------------------------

  no changes
  Inclusive step time: 0.0091860294342041


<- Leaving step build, name 'builder'
-------------------------------------

  no changes
  Inclusive step time: 0.0093400478363037


<- Leaving step build, name 'endpoint-resolution'
-------------------------------------------------

  no changes
  Inclusive step time: 0.011069059371948


<- Leaving step build, name 'auth-selection'
--------------------------------------------

  no changes
  Inclusive step time: 0.011813879013062


<- Leaving step validate, name 'input_validation_middleware'
------------------------------------------------------------

  no changes
  Inclusive step time: 0.01187801361084


<- Leaving step validate, name 'validation'
-------------------------------------------

  no changes
  Inclusive step time: 0.011955976486206


<- Leaving step init, name 's3.head_object'
-------------------------------------------

  no changes
  Inclusive step time: 0.012264013290405


<- Leaving step init, name 's3.auto_encode'
-------------------------------------------

  no changes
  Inclusive step time: 0.012318134307861


<- Leaving step init, name 's3.location'
----------------------------------------

  no changes
  Inclusive step time: 0.012372016906738


<- Leaving step init, name 's3.save_as'
---------------------------------------

  no changes
  Inclusive step time: 0.012421846389771


<- Leaving step init, name 's3.source_file'
-------------------------------------------

  no changes
  Inclusive step time: 0.012495994567871


<- Leaving step init, name 's3.ssec'
------------------------------------

  no changes
  Inclusive step time: 0.012582063674927


<- Leaving step init, name 'idempotency_auto_fill'
--------------------------------------------------

  no changes
  Inclusive step time: 0.012887001037598


   Aws\S3\Exception\S3Exception 

  Error executing "DeleteObjects" on "http://192.168.22.50:9000/default?delete"; AWS HTTP error: Client error: `POST http://192.168.22.50:9000/default?delete` resulted in a `400 Bad Request` response:
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>MissingContentMD5</Code><Message>Missing required header for this re (truncated...)
 MissingContentMD5 (client): Missing required header for this request: Content-Md5. - <?xml version="1.0" encoding="UTF-8"?>
<Error><Code>MissingContentMD5</Code><Message>Missing required header for this request: Content-Md5.</Message><BucketName>default</BucketName><Resource>/default</Resource><RequestId>181EE46F572C9D03</RequestId><HostId>dd9025bab4ad464b049177c95eb6ebf374d3b3fd1af9251148b658df7ac2e3e8</HostId></Error>

  at vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php:196
    192▕         $parts['request'] = $request;
    193▕         $parts['connection_error'] = !empty($err['connection_error']);
    194▕         $parts['transfer_stats'] = $stats;
    195▕ 
  ➜ 196▕         return new $this->exceptionClass(
    197▕             sprintf(
    198▕                 'Error executing "%s" on "%s"; %s',
    199▕                 $command->getName(),
    200▕                 $request->getUri(),

      +20 vendor frames 
  21  app/Console/Commands/Escombros.php:71
      Aws\AwsClient::__call()

      +12 vendor frames 
  34  artisan:35
      Illuminate\Foundation\Console\Kernel::handle()

Reproduction Steps

            echo $s3->getCnx()->deleteObjects([
                'Bucket' => 'default',
                'Delete' => [
                    'Objects' => array(array('Key'=>'20250125/02/7d26e317b3f22e38b4278e7431c20907')),
                ],
            ]);

Possible Solution

No response

Additional Information/Context

No response

SDK version used

3.339.0

Environment details (Version of PHP (php -v)? OS name and version, etc.)

PHP 8.3.1, Laravel Framework 10.48.27

@asterissco asterissco added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 28, 2025
@asterissco
Copy link
Author

For now my solution is downgrade version

qrms@pre:/opt/qualitas/common/backend$ composer.phar require aws/aws-sdk-php "3.296.1"

./composer.json has been updated
Running composer update aws/aws-sdk-php
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 1 update, 0 removals
  - Downgrading aws/aws-sdk-php (3.339.0 => 3.296.1)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
  - Downgrading aws/aws-sdk-php (3.339.0 => 3.296.1): Extracting archive

And works fine

            
            $s3response = $s3->getCnx()->deleteObjects([
                'Bucket' => 'default',
                'Delete' => [
                    'Objects' => $arrKey,
                ],
            ]);

            echo "Deleted ".(count($s3response->toArray()['Deleted']));
            echo PHP_EOL;

Output

Deleted 4

@mamchyts
Copy link

#3066 (comment)

@stobrien89 stobrien89 self-assigned this Jan 28, 2025
@stobrien89 stobrien89 added bug This issue is a bug. breaking-change Issue requires a breaking change to remediate. and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 28, 2025
@stobrien89
Copy link
Member

Hi all,

Sorry for the issues. Working on a fix for this. It is possible we'll have something out in today's release.

Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

@stobrien89
Copy link
Member

From #3066; also wanted to post here for visibility:

Hi all,

Apologies for the issues. I wanted to provide a workaround for those affected by the MD5 requirements on DELETE operations:

<?php

require 'vendor/autoload.php';

use Aws\S3\S3Client;
use Aws\Middleware;
use GuzzleHttp\Psr7\Utils;

$s3Client = new S3Client([
    'region'  => 'your-region'
]);

$handlerList = $s3Client->getHandlerList();
$handlerList->appendBuild(
    Middleware::mapRequest(static function ($request) {
        $body = $request->getBody();
        $contentMd5 = base64_encode(Utils::hash($body, 'md5', true));

        return $request->withHeader('Content-MD5', $contentMd5);
    })
);

$result = $s3Client->deleteObjects([
    'Bucket' => 'your-bucket-name',
    'Delete' => [
        'Objects' => [
            ['Key' => 'object-key-1.txt'],
            ['Key' => 'object-key-2.txt']
        ]
    ],
]);

We don't plan to introduce any opt-ins to MD5 checksums, but HandlerList extensibility makes it relatively easy to override the default behavior.

@asterissco
Copy link
Author

Thanks @stobrien89, now works fine!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Issue requires a breaking change to remediate. bug This issue is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants