CopyObjectAsync throws AmazonUnmarshallingException when the SourceBucket is null
tkarpli opened this issue · comments
tkarpli commented
Describe the bug
Call to CopyObjectAsync with SourceBucket null and existing DestinationBucket throws AmazonUnmarshallingException instead of AmazonS3Exception
Expected Behavior
CopyObjectAsync returns easily understandable exception like AmazonS3Exception with Error Code - InvalidArgument, the same as the direct call to AWS S3.
Current Behavior
Amazon.Runtime.AmazonUnmarshallingException: Error unmarshalling response back from AWS. HTTP Status Code: 200 OK ---> System.Xml.XmlException: Root element is missing.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at Amazon.Runtime.Internal.Transform.XmlUnmarshallerContext.Read() in C:\codebuild\tmp\output\src2898523126\src\aws-sdk-net\sdk\src\Core\Amazon.Runtime\Internal\Transform\UnmarshallerContext.cs:line 490
at Amazon.S3.Model.Internal.MarshallTransformations.S3UnmarshallerContext.Read() in C:\codebuild\tmp\output\src2898523126\src\aws-sdk-net\sdk\src\Services\S3\Custom\Model\Internal\MarshallTransformations\S3UnmarshallerContext.cs:line 64
at Amazon.S3.Model.Internal.MarshallTransformations.CopyObjectResponseUnmarshaller.Unmarshall(XmlUnmarshallerContext context) in C:\codebuild\tmp\output\src2898523126\src\aws-sdk-net\sdk\src\Services\S3\Custom\Model\Internal\MarshallTransformations\CopyObjectResponseUnmarshaller.cs:line 36
at Amazon.Runtime.Internal.Transform.XmlResponseUnmarshaller.Unmarshall(UnmarshallerContext input) in C:\codebuild\tmp\output\src2898523126\src\aws-sdk-net\sdk\src\Core\Amazon.Runtime\Internal\Transform\ResponseUnmarshallers.cs:line 128
at Amazon.S3.Model.Internal.MarshallTransformations.S3ReponseUnmarshaller.Unmarshall(UnmarshallerContext input) in C:\codebuild\tmp\output\src2898523126\src\aws-sdk-net\sdk\src\Services\S3\Custom\Model\Internal\MarshallTransformations\S3ReponseUnmarshaller.cs:line 62
at Amazon.Runtime.Internal.Transform.ResponseUnmarshaller.UnmarshallResponse(UnmarshallerContext context) in C:\codebuild\tmp\output\src2898523126\src\aws-sdk-net\sdk\src\Core\Amazon.Runtime\Internal\Transform\ResponseUnmarshallers.cs:line 88
at Amazon.Runtime.Internal.Unmarshaller.UnmarshallResponse(UnmarshallerContext context, IRequestContext requestContext) in C:\codebuild\tmp\output\src2898523126\src\aws-sdk-net\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\Unmarshaller.cs:line 213
at Amazon.Runtime.Internal.Unmarshaller.Unmarshall(IExecutionContext executionContext) in C:\codebuild\tmp\output\src2898523126\src\aws-sdk-net\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\Unmarshaller.cs:line 136
--- End of inner exception stack trace ---
at Amazon.Runtime.Internal.Unmarshaller.Unmarshall(IExecutionContext executionContext) in C:\codebuild\tmp\output\src2898523126\src\aws-sdk-net\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\Unmarshaller.cs:line 151
at Amazon.Runtime.Internal.Unmarshaller.<InvokeAsync>d__3`1.MoveNext() in C:\codebuild\tmp\output\src2898523126\src\aws-sdk-net\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\Unmarshaller.cs:line 70
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Amazon.S3.Internal.AmazonS3ResponseHandler.<InvokeAsync>d__1`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Amazon.Runtime.Internal.ErrorHandler.<InvokeAsync>d__5`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Amazon.Runtime.Internal.ErrorHandler.<InvokeAsync>d__5`1.MoveNext() in C:\codebuild\tmp\output\src2898523126\src\aws-sdk-net\sdk\src\Core\Amazon.Runtime\Pipeline\ErrorHandler\ErrorHandler.cs:line 107
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Amazon.Runtime.Internal.CallbackHandler.<InvokeAsync>d__9`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Amazon.Runtime.Internal.Signer.<InvokeAsync>d__1`1.MoveNext() in C:\codebuild\tmp\output\src2898523126\src\aws-sdk-net\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\Signer.cs:line 56
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Amazon.S3.Internal.S3Express.S3ExpressPreSigner.<InvokeAsync>d__5`1.MoveNext() in C:\codebuild\tmp\output\src2898523126\src\aws-sdk-net\sdk\src\Services\S3\Custom\Internal\S3Express\S3ExpressPreSigner.cs:line 101
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Amazon.Runtime.Internal.EndpointDiscoveryHandler.<InvokeAsync>d__2`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Amazon.Runtime.Internal.EndpointDiscoveryHandler.<InvokeAsync>d__2`1.MoveNext() in C:\codebuild\tmp\output\src2898523126\src\aws-sdk-net\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\EndpointDiscoveryHandler.cs:line 79
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Amazon.Runtime.Internal.CredentialsRetriever.<InvokeAsync>d__7`1.MoveNext() in C:\codebuild\tmp\output\src2898523126\src\aws-sdk-net\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\CredentialsRetriever.cs:line 98
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Amazon.Runtime.Internal.RetryHandler.<InvokeAsync>d__10`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Amazon.Runtime.Internal.RetryHandler.<InvokeAsync>d__10`1.MoveNext() in C:\codebuild\tmp\output\src2898523126\src\aws-sdk-net\sdk\src\Core\Amazon.Runtime\Pipeline\RetryHandler\RetryHandler.cs:line 146
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Amazon.Runtime.Internal.CallbackHandler.<InvokeAsync>d__9`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Amazon.Runtime.Internal.CallbackHandler.<InvokeAsync>d__9`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Amazon.S3.Internal.AmazonS3ExceptionHandler.<InvokeAsync>d__1`1.MoveNext() in C:\codebuild\tmp\output\src2898523126\src\aws-sdk-net\sdk\src\Services\S3\Custom\Internal\AmazonS3ExceptionHandler.cs:line 62
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Amazon.Runtime.Internal.ErrorCallbackHandler.<InvokeAsync>d__5`1.MoveNext() in C:\codebuild\tmp\output\src2898523126\src\aws-sdk-net\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\ErrorCallbackHandler.cs:line 58
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Amazon.Runtime.Internal.MetricsHandler.<InvokeAsync>d__1`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
Reproduction Steps
var request = new CopyObjectRequest() { SourceBucket = null, SourceKey = "anySourceKey",
DestinationBucket = "existing-bucket-copy-to", DestinationKey = "anyDestinationKey" };
await client.CopyObjectAsync(request);`
DestinationBucket should exist
Possible Solution
No response
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
AWSSDK.Core 3.7.302.12
AWSSDK.S3 3.7.305.28
Targeted .NET Platform
.NET Framework 4.7.2, .NET 7
Operating System and version
Windows 10