dresswithpockets / FakeS3

in-memory and on-disk S3 provider for .NET
https://dresswithpockets.github.io/FakeS3
Apache License 2.0
3 stars 1 forks source link

Getting XML-related exception when listing or deleting buckets #1

Closed vadim-kor closed 1 year ago

vadim-kor commented 2 years ago

Hello, here is what it brings. I'm using .Net6 though

System.InvalidOperationException: Cannot set a value on node type 'Element'. at System.Xml.XmlNode.set_Value(String value) at FakeS3.Internal.XmlAdapter.Buckets(IEnumerable`1 buckets) at FakeS3.Internal.FakeS3HttpMessageHandler.DoListBucketsAsync(FakeS3Request fakeRequest) at FakeS3.Internal.FakeS3HttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)

at System.Net.Http.HttpMessageInvoker.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) 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) at Amazon.Runtime.Internal.ErrorHandler.InvokeAsync[T](IExecutionContext executionContext) at Amazon.Runtime.Internal.CallbackHandler.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) at Amazon.S3.Util.AmazonS3Util.DoesS3BucketExistV2Async(IAmazonS3 s3Client, String bucketName)

dresswithpockets commented 2 years ago

What version of the AWSSDK.S3 and AWSSDK.Core packages are you using? The latest version this is test with are 3.7.3.8 and 3.7.3.15 respectively.

herebebeasties commented 2 months ago

This is still happening. It is annoying because it prevents ListObjectsV2Async from working.

The issue is in code like this: https://github.com/dresswithpockets/FakeS3/blob/de3155beb6906e2ca5eb093e2a35fbb2d5b07dce/src/FakeS3/Internal/XmlAdapter.cs#L20-L23

It needs to be written like so instead:

            var ownerId = xmlDoc.CreateElement("ID");
            var ownerName = xmlDoc.CreateElement("DisplayName");
            ownerId.InnerText = "123";
            ownerName.InnerText = "FakeS3";

This issue is present in a few places in this file.