You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to copy not existing object s3 client throws an exception with error code NoSuchKey and CopyObjectResponse is null.
Expected Behavior
I would say we should provide error in CopyObjectRequest. At least we should set an appropriate http status code.
Also it's not clear how a library consumer should determine that it's an issue with source key, cause the only way I see here is to check that ErrorCode == "NoSuchKey" what seems weird.
Current Behavior
Amazon.S3.AmazonS3Exception: The specified key does not exist.
---> Amazon.Runtime.Internal.HttpErrorResponseException: Exception of type 'Amazon.Runtime.Internal.HttpErrorResponseException' was thrown.
at Amazon.Runtime.HttpWebRequestMessage.GetResponseAsync(CancellationToken cancellationToken)
at Amazon.Runtime.Internal.HttpHandler`1.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.RedirectHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.Unmarshaller.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.S3.Internal.AmazonS3ResponseHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.ErrorHandler.InvokeAsync[T](IExecutionContext executionContext)
--- End of inner exception stack trace ---
at Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.HandleExceptionStream(IRequestContext requestContext, IWebResponseData httpErrorResponse, HttpErrorResponseException exception, Stream responseStream)
at Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.HandleExceptionAsync(IExecutionContext executionContext, HttpErrorResponseException exception)
at Amazon.Runtime.Internal.ExceptionHandler`1.HandleAsync(IExecutionContext executionContext, Exception exception)
at Amazon.Runtime.Internal.ErrorHandler.ProcessExceptionAsync(IExecutionContext executionContext, Exception exception)
at Amazon.Runtime.Internal.ErrorHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.Signer.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.EndpointDiscoveryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.EndpointDiscoveryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CredentialsRetriever.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.S3.Internal.AmazonS3ExceptionHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.ErrorCallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.MetricsHandler.InvokeAsync[T](IExecutionContext executionContext)
Reproduction Steps
Execute CopyObjectAsync on s3 client passing not existing SourceKey.
Possible Solution
Don't throw an exception but pass error context into CopyObjectResponse object
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
AWSSDK.S3 3.7.107.5
Targeted .NET Platform
.NET 7
Operating System and version
OSX Ventura 13.4.1
The text was updated successfully, but these errors were encountered:
@olizarevichroman Good morning. Thanks for reporting the concern. The behavior to throw an exception is as per design. The behavior is also controlled by service models which may define what exceptions a particular service operation may throw (for example NoSuchKey). This behavior is uniform across all AWS SDK(s) and is unlikely to change.
For your use case, you may develop a middleware with POCO object for each service operation that could have a shape with members like StatusCode and <ServiceOperation>Response object, where your middleware would catch specific exceptions and returns POCO object with specified status code to the caller.
I'm converting this to Q&A discussion since the behavior is unlikely to change and is as per design.
Describe the bug
When trying to copy not existing object s3 client throws an exception with error code NoSuchKey and
CopyObjectResponse
isnull
.Expected Behavior
I would say we should provide error in
CopyObjectRequest
. At least we should set an appropriate http status code.Also it's not clear how a library consumer should determine that it's an issue with source key, cause the only way I see here is to check that
ErrorCode == "NoSuchKey"
what seems weird.Current Behavior
Reproduction Steps
Execute
CopyObjectAsync
on s3 client passing not existingSourceKey
.Possible Solution
Don't throw an exception but pass error context into
CopyObjectResponse
objectAdditional Information/Context
No response
AWS .NET SDK and/or Package version used
AWSSDK.S3 3.7.107.5
Targeted .NET Platform
.NET 7
Operating System and version
OSX Ventura 13.4.1
The text was updated successfully, but these errors were encountered: