aws / aws-sdk-php

Official repository of the AWS SDK for PHP (@awsforphp)
http://aws.amazon.com/sdkforphp
Apache License 2.0
6k stars 1.21k forks source link

fprintf(): supplied resource is not a valid stream resource #2856

Open VadimSafonov opened 9 months ago

VadimSafonov commented 9 months ago

Describe the bug

After fix #2855 new error if Aws\S3\S3Client created with debug with logfn

Uncaught Exception fprintf(): supplied resource is not a valid stream resource Stack trace: #0 /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php(514): fprintf(Resource id #637, '<%s> [%s] ', 'GET https://tes...', 'PROGRESS')

1 [internal function]: GuzzleHttp\Handler\StreamHandler->GuzzleHttp\Handler{closure}(7, 0, NULL, 0, 7671, 73602)

2

/project/vendor/guzzlehttp/psr7/src/Stream.php(228): fread(Resource id #642, 8192)

3

/project/vendor/aws/aws-sdk-php/src/S3/StreamWrapper.php(209): GuzzleHttp\Psr7\Stream->read(8192)

4 [internal function]: Aws\S3\StreamWrapper->stream_read(8192)

5

/project/vendor/symfony/filesystem/Filesystem.php(62): stream_copy_to_stream(Resource id #643, Resource id #645)

Expected Behavior

no error

Current Behavior

error

Reproduction Steps

copy file to s3

Possible Solution

No response

Additional Information/Context

No response

SDK version used

3.293.10

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

PHP 8.2.13 (cli) (built: Nov 24 2023 13:15:01) (NTS) Copyright (c) The PHP Group Zend Engine v4.2.13, Copyright (c) Zend Technologies with Zend OPcache v8.2.13, Copyright (c), by Zend Technologies

yenfryherrerafeliz commented 9 months ago

Hi @VadimSafonov, sorry to hear about your issues. Can you please provide a minimal reproducible code so we can better investigate this?. For example, we would be able to see if happens by you providing a custom logfn, or if happens with the default logfn, which can be seen here. Our default implementation will use echo to display the value.

I look forward to your response.

Thanks!

VadimSafonov commented 9 months ago

Hi @yenfryherrerafeliz

I notice the following: 1 with default debug block config I got error, but file has been downloaded 2 without debug block config NO error, file has been downloaded

**There is reproduce code** ```php "latest", "region" => "us-east-1", "retries" => 5, "use_accelerate_endpoint" => true, "credentials" => [ "key" => "my_key", "secret" => "my_secret", ], "debug" => [ 'logfn' => function ($value) { echo $value; }, 'stream_size' => 524288, 'scrub_auth' => true, 'http' => true, 'auth_strings' => [], 'auth_headers' => [] ] ]); $s3->registerStreamWrapper(); copy("path_to_file", __DIR__ . "/var/aws_download.pdf"); ``` **and i got error and log** ``` -> Entering step init, name 'idempotency_auto_fill' --------------------------------------------------- command was set to array(3) { ["instance"]=> string(32) "000000001251b3390000000058fd7477" ["name"]=> string(10) "HeadObject" ["params"]=> array(4) { ["Bucket"]=> string(12) "test-unvsoft" ["Key"]=> string(50) "vadim/files/{37AEAC04-A6A7-D18A-71F0-124E6E71757A}" ["@http"]=> array(1) { ["debug"]=> resource(192) 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' -------------------------------------------- command.params.@http.decode_content was set to -> Entering step validate, name 'validation' -------------------------------------------- no changes -> Entering step validate, name 'input_validation_middleware' ------------------------------------------------------------- no changes -> Entering step build, name 'endpoint-resolution' -------------------------------------------------- no changes -> Entering step build, name 'builder' -------------------------------------- request.instance was set to 000000001251b3c00000000058fd7477 request.method was set to HEAD request.headers was set to array(2) { ["X-Amz-Security-Token"]=> string(7) "[TOKEN]" ["Host"]=> array(1) { [0]=> string(40) "test-unvsoft.s3-accelerate.amazonaws.com" } } request.scheme was set to https request.path was set to /vadim/files/%7B37AEAC04-A6A7-D18A-71F0-124E6E71757A%7D -> 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 000000001251b3c00000000058fd7477 to 000000001251b0a80000000058fd7477 request.headers.X-Amz-User-Agent was set to array(1) { [0]=> string(53) "aws-sdk-php/3.293.10 OS/Darwin#21.6.0 lang/php#7.2.34" } request.headers.User-Agent was set to array(1) { [0]=> string(53) "aws-sdk-php/3.293.10 OS/Darwin#21.6.0 lang/php#7.2.34" } -> Entering step build, name 'endpoint_parameter' ------------------------------------------------- no changes -> Entering step build, name 'EndpointDiscoveryMiddleware' ---------------------------------------------------------- no changes -> Entering step build, name 'request-compression' -------------------------------------------------- no changes -> Entering step build, name 'recursion-detection' -------------------------------------------------- no changes -> Entering step build, name 's3.checksum' ------------------------------------------ no changes -> 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 000000001251b0a80000000058fd7477 to 000000001251b0b30000000058fd7477 request.headers.aws-sdk-invocation-id was set to array(1) { [0]=> string(32) "0e7ea559daaecfcbed7828d95372660d" } -> Entering step sign, name 'retry' ----------------------------------- request.instance changed from 000000001251b0b30000000058fd7477 to 000000001251b0a60000000058fd7477 request.headers.aws-sdk-retry was set to array(1) { [0]=> string(3) "0/0" } -> Entering step sign, name 'signer' ------------------------------------ request.instance changed from 000000001251b0a60000000058fd7477 to 000000001251b09d0000000058fd7477 request.headers.x-amz-content-sha256 was set to array(1) { [0]=> string(64) "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" } request.headers.X-Amz-Date was set to array(1) { [0]=> string(16) "20231214T193542Z" } request.headers.Authorization was set to array(1) { [0]=> string(228) "AWS4-HMAC-SHA256 Credential=[KEY]/20231214/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date;x-amz-user-agent, Signature=[SIGNATURE] } -> 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 * Host test-unvsoft.s3-accelerate.amazonaws.com:443 was resolved. * IPv6: (none) * IPv4: 18.165.125.87 * Trying 18.165.125.87:443... * Connected to test-unvsoft.s3-accelerate.amazonaws.com (18.165.125.87) port 443 * ALPN: curl offers http/1.1 * SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256 / x25519 / RSASSA-PSS * ALPN: server did not agree on a protocol. Uses default. * Server certificate: * subject: CN=*.s3-accelerate.amazonaws.com * start date: Jul 17 00:00:00 2023 GMT * expire date: Mar 17 23:59:59 2024 GMT * subjectAltName: host "test-unvsoft.s3-accelerate.amazonaws.com" matched cert's "*.s3-accelerate.amazonaws.com" * issuer: C=US; O=Amazon; CN=Amazon RSA 2048 M01 * SSL certificate verify ok. * Certificate level 0: Public key type RSA (2048/112 Bits/secBits), signed using sha256WithRSAEncryption * Certificate level 1: Public key type RSA (2048/112 Bits/secBits), signed using sha256WithRSAEncryption * Certificate level 2: Public key type RSA (2048/112 Bits/secBits), signed using sha256WithRSAEncryption * using HTTP/1.x > HEAD /vadim/files/%7B37AEAC04-A6A7-D18A-71F0-124E6E71757A%7D HTTP/1.1 Host: test-unvsoft.s3-accelerate.amazonaws.com X-Amz-User-Agent: aws-sdk-php/3.293.10 OS/Darwin#21.6.0 lang/php#7.2.34 aws-sdk-invocation-id: 0e7ea559daaecfcbed7828d95372660d aws-sdk-retry: 0/0 x-amz-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 X-Amz-Date: 20231214T193542Z Authorization: AWS4-HMAC-SHA256 Credential=[KEY]/20231214/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date;x-amz-user-agent, Signature=[SIGNATURE] User-Agent: aws-sdk-php/3.293.10 OS/Darwin#21.6.0 lang/php#7.2.34 GuzzleHttp/6.5.5 curl/8.5.0 PHP/7.2.34 < HTTP/1.1 200 OK < Content-Type: application/octet-stream < Content-Length: 23501 < Connection: keep-alive < x-amz-id-2: SBVRuVeb0LpXQYw3H56tvIXZmv6zCWHUMDWmYXp0KnQ1X7PdPDnRLlXYafsolu46R4MndrTPFxo= < x-amz-request-id: GZRSYJA37Q20GCMP < Date: Thu, 14 Dec 2023 19:35:43 GMT < Last-Modified: Thu, 14 Dec 2023 18:14:07 GMT < ETag: "660a5324d7f84bbecb25600021b4376f" < x-amz-server-side-encryption: AES256 < Accept-Ranges: bytes < Server: AmazonS3 < X-Cache: Miss from cloudfront < Via: 1.1 235bf7a65ed49d73ef3ff61018265510.cloudfront.net (CloudFront) < X-Amz-Cf-Pop: HEL51-P2 < X-Amz-Cf-Id: deWZWdQg7pFtWyGuDHf5_5d0UbtFjvf5IaokK50fSU3s9kQ18jdTug== < * Connection #0 to host test-unvsoft.s3-accelerate.amazonaws.com left intact <- Leaving step attempt, name 'ApiCallAttemptMonitoringMiddleware' ------------------------------------------------------------------ result was set to array(2) { ["instance"]=> string(32) "000000001251b0300000000058fd7477" ["data"]=> array(35) { ["DeleteMarker"]=> bool(false) ["AcceptRanges"]=> string(5) "bytes" ["Expiration"]=> string(0) "" ["Restore"]=> string(0) "" ["ArchiveStatus"]=> string(0) "" ["LastModified"]=> object(Aws\Api\DateTimeResult)#681 (3) { ["date"]=> string(26) "2023-12-14 18:14:07.000000" ["timezone_type"]=> int(2) ["timezone"]=> string(3) "GMT" } ["ContentLength"]=> int(23501) ["ChecksumCRC32"]=> string(0) "" ["ChecksumCRC32C"]=> string(0) "" ["ChecksumSHA1"]=> string(0) "" ["ChecksumSHA256"]=> string(0) "" ["ETag"]=> string(34) ""660a5324d7f84bbecb25600021b4376f"" ["MissingMeta"]=> string(0) "" ["VersionId"]=> string(0) "" ["CacheControl"]=> string(0) "" ["ContentDisposition"]=> string(0) "" ["ContentEncoding"]=> string(0) "" ["ContentLanguage"]=> string(0) "" ["ContentType"]=> string(24) "application/octet-stream" ["Expires"]=> object(Aws\Api\DateTimeResult)#682 (3) { ["date"]=> string(26) "1970-01-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } ["WebsiteRedirectLocation"]=> string(0) "" ["ServerSideEncryption"]=> string(6) "AES256" ["Metadata"]=> array(0) { } ["SSECustomerAlgorithm"]=> string(0) "" ["SSECustomerKeyMD5"]=> string(0) "" ["SSEKMSKeyId"]=> string(0) "" ["BucketKeyEnabled"]=> bool(false) ["StorageClass"]=> string(0) "" ["RequestCharged"]=> string(0) "" ["ReplicationStatus"]=> string(0) "" ["PartsCount"]=> string(0) "" ["ObjectLockMode"]=> string(0) "" ["ObjectLockRetainUntilDate"]=> object(Aws\Api\DateTimeResult)#683 (3) { ["date"]=> string(26) "1970-01-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } ["ObjectLockLegalHoldStatus"]=> string(0) "" ["@metadata"]=> array(4) { ["statusCode"]=> int(200) ["effectiveUri"]=> string(103) "https://test-unvsoft.s3-accelerate.amazonaws.com/vadim/files/%7B37AEAC04-A6A7-D18A-71F0-124E6E71757A%7D" ["headers"]=> array(15) { ["content-type"]=> string(24) "application/octet-stream" ["content-length"]=> string(5) "23501" ["connection"]=> string(10) "keep-alive" ["x-amz-id-2"]=> string(76) "SBVRuVeb0LpXQYw3H56tvIXZmv6zCWHUMDWmYXp0KnQ1X7PdPDnRLlXYafsolu46R4MndrTPFxo=" ["x-amz-request-id"]=> string(16) "GZRSYJA37Q20GCMP" ["date"]=> string(29) "Thu, 14 Dec 2023 19:35:43 GMT" ["last-modified"]=> string(29) "Thu, 14 Dec 2023 18:14:07 GMT" ["etag"]=> string(34) ""660a5324d7f84bbecb25600021b4376f"" ["x-amz-server-side-encryption"]=> string(6) "AES256" ["accept-ranges"]=> string(5) "bytes" ["server"]=> string(8) "AmazonS3" ["x-cache"]=> string(20) "Miss from cloudfront" ["via"]=> string(64) "1.1 235bf7a65ed49d73ef3ff61018265510.cloudfront.net (CloudFront)" ["x-amz-cf-pop"]=> string(8) "HEL51-P2" ["x-amz-cf-id"]=> string(56) "deWZWdQg7pFtWyGuDHf5_5d0UbtFjvf5IaokK50fSU3s9kQ18jdTug==" } ["transferStats"]=> array(0) { } } } } Inclusive step time: 0.36006808280945 <- Leaving step sign, name 's3.permanent_redirect' -------------------------------------------------- no changes Inclusive step time: 0.36014318466187 <- Leaving step sign, name 's3.put_object_url' ---------------------------------------------- no changes Inclusive step time: 0.36021995544434 <- Leaving step sign, name 'signer' ----------------------------------- no changes Inclusive step time: 0.3603298664093 <- Leaving step sign, name 'retry' ---------------------------------- no changes Inclusive step time: 0.36181402206421 <- Leaving step sign, name 'invocation-id' ------------------------------------------ result.data.@metadata.transferStats.http was set to array(1) { [0]=> array(0) { } } Inclusive step time: 0.36196994781494 <- Leaving step sign, name 'StreamRequestPayloadMiddleware' ----------------------------------------------------------- no changes Inclusive step time: 0.36204314231873 <- Leaving step build, name 's3.bucket_endpoint_arn' ---------------------------------------------------- no changes Inclusive step time: 0.36211013793945 <- Leaving step build, name 's3.content_type' --------------------------------------------- no changes Inclusive step time: 0.36228084564209 <- Leaving step build, name 's3.checksum' ----------------------------------------- no changes Inclusive step time: 0.36233305931091 <- Leaving step build, name 'recursion-detection' ------------------------------------------------- no changes Inclusive step time: 0.36239504814148 <- Leaving step build, name 'request-compression' ------------------------------------------------- no changes Inclusive step time: 0.36244702339172 <- Leaving step build, name 'EndpointDiscoveryMiddleware' --------------------------------------------------------- no changes Inclusive step time: 0.36250686645508 <- Leaving step build, name 'endpoint_parameter' ------------------------------------------------ no changes Inclusive step time: 0.36256790161133 <- Leaving step build, name '' ------------------------------ no changes Inclusive step time: 0.36266493797302 <- Leaving step build, name 'ApiCallMonitoringMiddleware' --------------------------------------------------------- no changes Inclusive step time: 0.36277198791504 <- Leaving step build, name 's3.check_empty_path_with_query' ------------------------------------------------------------ no changes Inclusive step time: 0.36313700675964 <- Leaving step build, name 'builder' ------------------------------------- no changes Inclusive step time: 0.36367917060852 <- Leaving step build, name 'endpoint-resolution' ------------------------------------------------- no changes Inclusive step time: 0.36487889289856 <- Leaving step validate, name 'input_validation_middleware' ------------------------------------------------------------ no changes Inclusive step time: 0.36549687385559 <- Leaving step validate, name 'validation' ------------------------------------------- no changes Inclusive step time: 0.36555695533752 <- Leaving step init, name 's3.head_object' ------------------------------------------- no changes Inclusive step time: 0.36570000648499 <- Leaving step init, name 's3.auto_encode' ------------------------------------------- no changes Inclusive step time: 0.36574482917786 <- Leaving step init, name 's3.location' ---------------------------------------- no changes Inclusive step time: 0.3657910823822 <- Leaving step init, name 's3.save_as' --------------------------------------- no changes Inclusive step time: 0.36583495140076 <- Leaving step init, name 's3.source_file' ------------------------------------------- no changes Inclusive step time: 0.36587905883789 <- Leaving step init, name 's3.ssec' ------------------------------------ no changes Inclusive step time: 0.36594200134277 <- Leaving step init, name 'idempotency_auto_fill' -------------------------------------------------- no changes Inclusive step time: 0.36619901657104 -> Entering step init, name 'idempotency_auto_fill' --------------------------------------------------- command was set to array(3) { ["instance"]=> string(32) "000000001251b0300000000058fd7477" ["name"]=> string(9) "GetObject" ["params"]=> array(4) { ["Bucket"]=> string(12) "test-unvsoft" ["Key"]=> string(50) "vadim/files/{37AEAC04-A6A7-D18A-71F0-124E6E71757A}" ["@http"]=> array(2) { ["stream"]=> bool(true) ["debug"]=> resource(227) 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 'endpoint-resolution' -------------------------------------------------- no changes -> Entering step build, name 'builder' -------------------------------------- request.instance was set to 000000001251b0b70000000058fd7477 request.method was set to GET request.headers was set to array(2) { ["X-Amz-Security-Token"]=> string(7) "[TOKEN]" ["Host"]=> array(1) { [0]=> string(40) "test-unvsoft.s3-accelerate.amazonaws.com" } } request.scheme was set to https request.path was set to /vadim/files/%7B37AEAC04-A6A7-D18A-71F0-124E6E71757A%7D -> 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 000000001251b0b70000000058fd7477 to 000000001251b0290000000058fd7477 request.headers.X-Amz-User-Agent was set to array(1) { [0]=> string(53) "aws-sdk-php/3.293.10 OS/Darwin#21.6.0 lang/php#7.2.34" } request.headers.User-Agent was set to array(1) { [0]=> string(53) "aws-sdk-php/3.293.10 OS/Darwin#21.6.0 lang/php#7.2.34" } -> Entering step build, name 'endpoint_parameter' ------------------------------------------------- no changes -> Entering step build, name 'EndpointDiscoveryMiddleware' ---------------------------------------------------------- no changes -> Entering step build, name 'request-compression' -------------------------------------------------- no changes -> Entering step build, name 'recursion-detection' -------------------------------------------------- no changes -> Entering step build, name 's3.checksum' ------------------------------------------ no changes -> 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 000000001251b0290000000058fd7477 to 000000001251b02b0000000058fd7477 request.headers.aws-sdk-invocation-id was set to array(1) { [0]=> string(32) "028c02d8d6c8f3590c77806783299e75" } -> Entering step sign, name 'retry' ----------------------------------- request.instance changed from 000000001251b02b0000000058fd7477 to 000000001251b0250000000058fd7477 request.headers.aws-sdk-retry was set to array(1) { [0]=> string(3) "0/0" } -> Entering step sign, name 'signer' ------------------------------------ request.instance changed from 000000001251b0250000000058fd7477 to 000000001251b34f0000000058fd7477 request.headers.x-amz-content-sha256 was set to array(1) { [0]=> string(64) "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" } request.headers.X-Amz-Date was set to array(1) { [0]=> string(16) "20231214T193542Z" } request.headers.Authorization was set to array(1) { [0]=> string(228) "AWS4-HMAC-SHA256 Credential=[KEY]/20231214/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date;x-amz-user-agent, Signature=[SIGNATURE] } -> 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 [CONNECT] [MIME_TYPE_IS] message: "application/octet-stream" [FILE_SIZE_IS] message: "Content-Length: 23501" bytes_max: "23501" [PROGRESS] bytes_max: "23501" <- Leaving step attempt, name 'ApiCallAttemptMonitoringMiddleware' ------------------------------------------------------------------ result was set to array(2) { ["instance"]=> string(32) "000000001251b1b60000000058fd7477" ["data"]=> array(37) { ["Body"]=> object(GuzzleHttp\Psr7\Stream)#477 (7) { ["stream":"GuzzleHttp\Psr7\Stream":private]=> resource(232) of type (stream) ["size":"GuzzleHttp\Psr7\Stream":private]=> NULL ["seekable":"GuzzleHttp\Psr7\Stream":private]=> bool(false) ["readable":"GuzzleHttp\Psr7\Stream":private]=> bool(true) ["writable":"GuzzleHttp\Psr7\Stream":private]=> bool(false) ["uri":"GuzzleHttp\Psr7\Stream":private]=> string(103) "https://test-unvsoft.s3-accelerate.amazonaws.com/vadim/files/%7B37AEAC04-A6A7-D18A-71F0-124E6E71757A%7D" ["customMetadata":"GuzzleHttp\Psr7\Stream":private]=> array(0) { } } ["DeleteMarker"]=> bool(false) ["AcceptRanges"]=> string(5) "bytes" ["Expiration"]=> string(0) "" ["Restore"]=> string(0) "" ["LastModified"]=> object(Aws\Api\DateTimeResult)#807 (3) { ["date"]=> string(26) "2023-12-14 18:14:07.000000" ["timezone_type"]=> int(2) ["timezone"]=> string(3) "GMT" } ["ContentLength"]=> int(23501) ["ETag"]=> string(34) ""660a5324d7f84bbecb25600021b4376f"" ["ChecksumCRC32"]=> string(0) "" ["ChecksumCRC32C"]=> string(0) "" ["ChecksumSHA1"]=> string(0) "" ["ChecksumSHA256"]=> string(0) "" ["MissingMeta"]=> string(0) "" ["VersionId"]=> string(0) "" ["CacheControl"]=> string(0) "" ["ContentDisposition"]=> string(0) "" ["ContentEncoding"]=> string(0) "" ["ContentLanguage"]=> string(0) "" ["ContentRange"]=> string(0) "" ["ContentType"]=> string(24) "application/octet-stream" ["Expires"]=> object(Aws\Api\DateTimeResult)#808 (3) { ["date"]=> string(26) "1970-01-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } ["WebsiteRedirectLocation"]=> string(0) "" ["ServerSideEncryption"]=> string(6) "AES256" ["Metadata"]=> array(0) { } ["SSECustomerAlgorithm"]=> string(0) "" ["SSECustomerKeyMD5"]=> string(0) "" ["SSEKMSKeyId"]=> string(0) "" ["BucketKeyEnabled"]=> bool(false) ["StorageClass"]=> string(0) "" ["RequestCharged"]=> string(0) "" ["ReplicationStatus"]=> string(0) "" ["PartsCount"]=> string(0) "" ["TagCount"]=> string(0) "" ["ObjectLockMode"]=> string(0) "" ["ObjectLockRetainUntilDate"]=> object(Aws\Api\DateTimeResult)#809 (3) { ["date"]=> string(26) "1970-01-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } ["ObjectLockLegalHoldStatus"]=> string(0) "" ["@metadata"]=> array(4) { ["statusCode"]=> int(200) ["effectiveUri"]=> string(103) "https://test-unvsoft.s3-accelerate.amazonaws.com/vadim/files/%7B37AEAC04-A6A7-D18A-71F0-124E6E71757A%7D" ["headers"]=> array(15) { ["content-type"]=> string(24) "application/octet-stream" ["content-length"]=> string(5) "23501" ["connection"]=> string(5) "close" ["x-amz-id-2"]=> string(76) "OcnjBQ0nmzbQgRrr9K6mQ2Qi5KA/Z2q4sHexa+mhfAp/aziZ1PnMGxk4cctG5pfrVJ1CnY7/sL8=" ["x-amz-request-id"]=> string(16) "GZRGDMQXJ0HGG152" ["date"]=> string(29) "Thu, 14 Dec 2023 19:35:43 GMT" ["last-modified"]=> string(29) "Thu, 14 Dec 2023 18:14:07 GMT" ["etag"]=> string(34) ""660a5324d7f84bbecb25600021b4376f"" ["x-amz-server-side-encryption"]=> string(6) "AES256" ["accept-ranges"]=> string(5) "bytes" ["server"]=> string(8) "AmazonS3" ["x-cache"]=> string(20) "Miss from cloudfront" ["via"]=> string(64) "1.1 314739a512b2afae40702e1a95e8f8de.cloudfront.net (CloudFront)" ["x-amz-cf-pop"]=> string(8) "HEL51-P2" ["x-amz-cf-id"]=> string(56) "49-oZFsPUr3qVAIE5k-SehL1szfyM6z0SCdJgjX-hhfV9crfzTJFKw==" } ["transferStats"]=> array(0) { } } } } Inclusive step time: 0.32320094108582 <- Leaving step sign, name 's3.permanent_redirect' -------------------------------------------------- no changes Inclusive step time: 0.32329487800598 <- Leaving step sign, name 's3.put_object_url' ---------------------------------------------- no changes Inclusive step time: 0.3233630657196 <- Leaving step sign, name 'signer' ----------------------------------- no changes Inclusive step time: 0.3234601020813 <- Leaving step sign, name 'retry' ---------------------------------- no changes Inclusive step time: 0.32371497154236 <- Leaving step sign, name 'invocation-id' ------------------------------------------ result.data.@metadata.transferStats.http was set to array(1) { [0]=> array(0) { } } Inclusive step time: 0.32388997077942 <- Leaving step sign, name 'StreamRequestPayloadMiddleware' ----------------------------------------------------------- no changes Inclusive step time: 0.32396006584167 <- Leaving step build, name 's3.bucket_endpoint_arn' ---------------------------------------------------- no changes Inclusive step time: 0.32403206825256 <- Leaving step build, name 's3.content_type' --------------------------------------------- no changes Inclusive step time: 0.32411098480225 <- Leaving step build, name 's3.checksum' ----------------------------------------- no changes Inclusive step time: 0.32416701316833 <- Leaving step build, name 'recursion-detection' ------------------------------------------------- no changes Inclusive step time: 0.32423090934753 <- Leaving step build, name 'request-compression' ------------------------------------------------- no changes Inclusive step time: 0.32428598403931 <- Leaving step build, name 'EndpointDiscoveryMiddleware' --------------------------------------------------------- no changes Inclusive step time: 0.32434892654419 <- Leaving step build, name 'endpoint_parameter' ------------------------------------------------ no changes Inclusive step time: 0.32441306114197 <- Leaving step build, name '' ------------------------------ no changes Inclusive step time: 0.32450485229492 <- Leaving step build, name 'ApiCallMonitoringMiddleware' --------------------------------------------------------- no changes Inclusive step time: 0.32457208633423 <- Leaving step build, name 's3.check_empty_path_with_query' ------------------------------------------------------------ no changes Inclusive step time: 0.32470202445984 <- Leaving step build, name 'builder' ------------------------------------- no changes Inclusive step time: 0.32480812072754 <- Leaving step build, name 'endpoint-resolution' ------------------------------------------------- no changes Inclusive step time: 0.32498002052307 <- Leaving step validate, name 'input_validation_middleware' ------------------------------------------------------------ no changes Inclusive step time: 0.32508301734924 <- Leaving step validate, name 'validation' ------------------------------------------- no changes Inclusive step time: 0.32514905929565 <- Leaving step init, name 's3.head_object' ------------------------------------------- no changes Inclusive step time: 0.32527995109558 <- Leaving step init, name 's3.auto_encode' ------------------------------------------- no changes Inclusive step time: 0.32533717155457 <- Leaving step init, name 's3.location' ---------------------------------------- no changes Inclusive step time: 0.32539081573486 <- Leaving step init, name 's3.save_as' --------------------------------------- no changes Inclusive step time: 0.32543802261353 <- Leaving step init, name 's3.source_file' ------------------------------------------- no changes Inclusive step time: 0.32548785209656 <- Leaving step init, name 's3.ssec' ------------------------------------ no changes Inclusive step time: 0.32555103302002 <- Leaving step init, name 'idempotency_auto_fill' -------------------------------------------------- no changes Inclusive step time: 0.32564783096313 Warning: fprintf(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 514 Warning: fwrite(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 516 Warning: fwrite(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 516 Warning: fwrite(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 518 Warning: fprintf(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 514 Warning: fwrite(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 516 Warning: fwrite(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 516 Warning: fwrite(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 518 Warning: fprintf(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 514 Warning: fwrite(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 516 Warning: fwrite(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 516 Warning: fwrite(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 518 Warning: fprintf(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 514 Warning: fwrite(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 516 Warning: fwrite(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 516 Warning: fwrite(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 518 PHP Warning: fprintf(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 514 PHP Warning: fwrite(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 516 PHP Warning: fwrite(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 516 PHP Warning: fwrite(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 518 PHP Warning: fprintf(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 514 PHP Warning: fwrite(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 516 PHP Warning: fwrite(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 516 PHP Warning: fwrite(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 518 PHP Warning: fprintf(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 514 PHP Warning: fwrite(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 516 PHP Warning: fwrite(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 516 PHP Warning: fwrite(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 518 PHP Warning: fprintf(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 514 PHP Warning: fwrite(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 516 PHP Warning: fwrite(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 516 PHP Warning: fwrite(): supplied resource is not a valid stream resource in /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 518 Process finished with exit code 0 ```
yenfryherrerafeliz commented 8 months ago

Hi @VadimSafonov, I tried to reproduce the reported issue with the code that you have provided but I was not able to. Would you be able to please create a test project from scratch and see if the behavior occurs there?, just to discard any outdated implementation.

I look forward to your response.

Thanks!

VadimSafonov commented 8 months ago

Hi @yenfryherrerafeliz I attach test project error is the same aws-sdk-test.tar.gz

VadimSafonov commented 1 month ago

At the latest SDK version problem still exists Even if specify debug => true, not array with config params

yenfryherrerafeliz commented 1 month ago

Hi @VadimSafonov, I will work on identifying what may be causing this issue this week and get back to you as soon as possible.

Thanks!

RanVaknin commented 1 month ago

Hi @VadimSafonov ,

  1. I have tried to reproduce this behavior but I was unable to:
<?php

require 'vendor/autoload.php';

use Aws\S3\S3Client;

$s3Client = new S3Client([
    'version' => 'latest',
    'region'  => 'us-east-1',
    "debug" => [
        'logfn'        => function ($value) { echo $value; },
        'stream_size'  => 524288,
        'scrub_auth'   => true,
        'http'         => true,
        'auth_strings' => [],
        'auth_headers' => []
    ]
]);

$s3Client->registerStreamWrapper();

$localFilePath = "./text.txt";  
$s3DestinationPath = "s3://foo-bucket-REDACTED/destination-file2.txt";

try {
    if (copy($localFilePath, $s3DestinationPath)) {
        echo "File was copied successfully to S3.\n";
    } else {
        echo "Failed to copy the file to S3.\n";
    }
} catch (Exception $e) {
  echo "Error: " . $e->getMessage() . "\n";
}

// File was copied successfully to S3.
// no errors or warnings are shown.

I tried this both with the 'debug': true, and with the debug an array options and neither one is causing the warning you have seen to be surfaced. Can you take a look at my code and see if I'm missing anything?

For reference Im using PHP 8.3.10 and "aws/aws-sdk-php": "3.318.0" Can you try upgrading and see if this solves your issue?

Thanks, Ran~

github-actions[bot] commented 2 weeks ago

This issue has not recieved a response in 1 week. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled.

VadimSafonov commented 2 weeks ago

Ok. I'll try to run the code on php 8.3 I need some time

VadimSafonov commented 2 weeks ago

Hi @RanVaknin In your reproduce case you copy file from local to s3. This case works fine for me too But when copy file from s3 to local there is an error

Stack trace:
#0 /Users/vadimsafonov/Documents/GitHub/aws-sdk-test/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php(591): fprintf(Resource id #214, '<%s> [%s] ', 'GET https://tes...', 'PROGRESS')
#1 [internal function]: GuzzleHttp\Handler\StreamHandler::GuzzleHttp\Handler\{closure}(7, 0, NULL, 0, 15756, 932438)
#2 /Users/vadimsafonov/Documents/GitHub/aws-sdk-test/vendor/guzzlehttp/psr7/src/Stream.php(234): fread(Resource id #219, 8192)
#3 /Users/vadimsafonov/Documents/GitHub/aws-sdk-test/vendor/aws/aws-sdk-php/src/S3/StreamWrapper.php(209): GuzzleHttp\Psr7\Stream->read(8192)
#4 [internal function]: Aws\S3\StreamWrapper->stream_read(8192)
#5 /Users/vadimsafonov/Documents/GitHub/aws-sdk-test/test.php(26): copy('s3://test-unvso...', '/Users/vadimsaf...')
#6 {main}
  thrown in /Users/vadimsafonov/Documents/GitHub/aws-sdk-test/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 591

Darwin Kernel Version 23.5.0 php 8.3.10 aws sdk 3.320.8