{"action":"closed","issue":{"url":"https://api.github.com/repos/aws/aws-sdk-net/issues/683","repository_url":"https://api.github.com/repos/aws/aws-sdk-net","labels_url":"https://api.github.com/repos/aws/aws-sdk-net/issues/683/labels{/name}","comments_url":"https://api.github.com/repos/aws/aws-sdk-net/issues/683/comments","events_url":"https://api.github.com/repos/aws/aws-sdk-net/issues/683/events","html_url":"https://github.com/aws/aws-sdk-net/issues/683","id":239258291,"number":683,"title":"Upload object through stream throws ThrowAddingDuplicateWithKeyArgumentException","user":{"login":"marcuslindblom","id":319720,"avatar_url":"https://avatars2.githubusercontent.com/u/319720?v=3","gravatar_id":"","url":"https://api.github.com/users/marcuslindblom","html_url":"https://github.com/marcuslindblom","followers_url":"https://api.github.com/users/marcuslindblom/followers","following_url":"https://api.github.com/users/marcuslindblom/following{/other_user}","gists_url":"https://api.github.com/users/marcuslindblom/gists{/gist_id}","starred_url":"https://api.github.com/users/marcuslindblom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcuslindblom/subscriptions","organizations_url":"https://api.github.com/users/marcuslindblom/orgs","repos_url":"https://api.github.com/users/marcuslindblom/repos","events_url":"https://api.github.com/users/marcuslindblom/events{/privacy}","received_events_url":"https://api.github.com/users/marcuslindblom/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-06-28T18:43:39Z","updated_at":"2017-06-28T19:34:29Z","closed_at":"2017-06-28T19:34:29Z","body":"<!--- Provide a general summary of the issue in the Title above -->\r\n\r\n## Expected Behavior\r\nUpload file success\r\n## Current Behavior\r\nI have an async method uploading files to my S3 bucket. This is how it's done:\r\n```c#\r\npublic async Task UploadFile(string id, Stream stream) \r\n{\r\n  try {\r\n    PutObjectRequest request = new PutObjectRequest()\r\n    {\r\n      BucketName = \"[BUCKETNAME]\",\r\n      Key = $\"{id}/images/thumbs/thumb.jpg\",\r\n      InputStream = stream\r\n    };\r\n    PutObjectResponse response = await _s3Client.PutObjectAsync(request);\r\n  }\r\n  catch(Exception ex) {\r\n    Console.WriteLine(ex.Message);\r\n  }\r\n}\r\n```\r\n\r\nBecause I'm using the accelerated endpoint I add the client in my `Startup.cs` like this:\r\n\r\n```c#\r\nvar awsOptions = Configuration.GetAWSOptions();\r\n\r\nvar credentialChains = new Amazon.Runtime.CredentialManagement.CredentialProfileStoreChain();\r\nAmazon.Runtime.AWSCredentials credentials;\r\nif(!credentialChains.TryGetAWSCredentials(awsOptions.Profile, out credentials))\r\n{\r\n    credentials = Amazon.Runtime.FallbackCredentialsFactory.GetCredentials();\r\n}\r\n\r\nvar s3Config = new AmazonS3Config\r\n{\r\n    RegionEndpoint = awsOptions.Region,\r\n    UseAccelerateEndpoint = true\r\n};\r\n\r\nservices.AddSingleton<IAmazonS3>(new AmazonS3Client(credentials, s3Config));\r\n```\r\n\r\nSometimes when I upload multiple files I get the following exception. This seems to be somewhat intermittent because I don't always get the exception but the upload fails silently.\r\n\r\n```\r\n\"   at System.ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException(Object key)\\n   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)\\n   at Amazon.RegionEndpoint.NewEndpoint(String systemName, String displayName) in E:\\\\JenkinsWorkspaces\\\\v3-trebuchet-release\\\\AWSDotNetPublic\\\\sdk\\\\src\\\\Core\\\\RegionEndpoint\\\\RegionEndpoint.cs:line 169\\n   at Amazon.RegionEndpoint.GetBySystemName(String systemName) in E:\\\\JenkinsWorkspaces\\\\v3-trebuchet-release\\\\AWSDotNetPublic\\\\sdk\\\\src\\\\Core\\\\RegionEndpoint\\\\RegionEndpoint.cs:line 153\\n   at Amazon.S3.Util.AmazonS3Uri..ctor(Uri uri)\\n   at Amazon.S3.Util.AmazonS3Uri.TryParseAmazonS3Uri(Uri uri, AmazonS3Uri& amazonS3Uri)\\n   at Amazon.S3.Internal.S3Signer.Sign(IRequest request, IClientConfig clientConfig, RequestMetrics metrics, String awsAccessKeyId, String awsSecretAccessKey)\\n   at Amazon.Runtime.Internal.Signer.SignRequest(IRequestContext requestContext) in E:\\\\JenkinsWorkspaces\\\\v3-trebuchet-release\\\\AWSDotNetPublic\\\\sdk\\\\src\\\\Core\\\\Amazon.Runtime\\\\Pipeline\\\\Handlers\\\\Signer.cs:line 127\\n   at Amazon.Runtime.Internal.Signer.PreInvoke(IExecutionContext executionContext) in E:\\\\JenkinsWorkspaces\\\\v3-trebuchet-release\\\\AWSDotNetPublic\\\\sdk\\\\src\\\\Core\\\\Amazon.Runtime\\\\Pipeline\\\\Handlers\\\\Signer.cs:line 83\\n   at Amazon.Runtime.Internal.Signer.InvokeAsync[T](IExecutionContext executionContext) in E:\\\\JenkinsWorkspaces\\\\v3-trebuchet-release\\\\AWSDotNetPublic\\\\sdk\\\\src\\\\Core\\\\Amazon.Runtime\\\\Pipeline\\\\Handlers\\\\Signer.cs:line 53\\n   at Amazon.Runtime.Internal.CredentialsRetriever.<InvokeAsync>d__7`1.MoveNext() in E:\\\\JenkinsWorkspaces\\\\v3-trebuchet-release\\\\AWSDotNetPublic\\\\sdk\\\\src\\\\Core\\\\Amazon.Runtime\\\\Pipeline\\\\Handlers\\\\CredentialsRetriever.cs:line 98\\n--- End of stack trace from previous location where exception was thrown ---\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\n   at Amazon.Runtime.Internal.RetryHandler.<InvokeAsync>d__10`1.MoveNext()\\n--- End of stack trace from previous location where exception was thrown ---\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\n   at Amazon.Runtime.Internal.RetryHandler.<InvokeAsync>d__10`1.MoveNext() in E:\\\\JenkinsWorkspaces\\\\v3-trebuchet-release\\\\AWSDotNetPublic\\\\sdk\\\\src\\\\Core\\\\Amazon.Runtime\\\\Pipeline\\\\RetryHandler\\\\RetryHandler.cs:line 131\\n--- End of stack trace from previous location where exception was thrown ---\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\n   at Amazon.Runtime.Internal.CallbackHandler.<InvokeAsync>d__9`1.MoveNext()\\n--- End of stack trace from previous location where exception was thrown ---\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\n   at Amazon.Runtime.Internal.CallbackHandler.<InvokeAsync>d__9`1.MoveNext()\\n--- End of stack trace from previous location where exception was thrown ---\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\n   at Amazon.S3.Internal.AmazonS3ExceptionHandler.<InvokeAsync>d__1`1.MoveNext()\\n--- End of stack trace from previous location where exception was thrown ---\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\n   at Amazon.Runtime.Internal.ErrorCallbackHandler.<InvokeAsync>d__5`1.MoveNext() in E:\\\\JenkinsWorkspaces\\\\v3-trebuchet-release\\\\AWSDotNetPublic\\\\sdk\\\\src\\\\Core\\\\Amazon.Runtime\\\\Pipeline\\\\Handlers\\\\ErrorCallbackHandler.cs:line 58\\n--- End of stack trace from previous location where exception was thrown ---\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\n   at Amazon.Runtime.Internal.MetricsHandler.<InvokeAsync>d__1`1.MoveNext()\\n--- End of stack trace from previous location where exception was thrown ---\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\n   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\\n   at Aperture.Controllers.WorkerController.<UploadFile>d__9.MoveNext() in /home/maqe/Projects/aperture/src/Controllers/WorkerController.cs:line 311\"\r\n```\r\n\r\nHow can I catch the error thrown by the client when uploading an object? The logging link only explains non .NET Core ways of doing logging?\r\n\r\n## Possible Solution\r\n<!--- Not required, but suggest a fix/reason for the bug, -->\r\n<!--- or ideas how to implement the addition or change -->\r\n\r\n## Steps to Reproduce (for bugs)\r\nUse the code above, upload 10 files rapidly\r\n<!--- Provide a self-contained, concise snippet of code that can be inserted into a -->\r\n<!--- basic .NET console application to replicate the bug -->\r\n<!--- For more complex issues provide a repo with the smallest sample that reproduces the bug -->\r\n<!--- Including business logic or unrelated code makes diagnosis more difficult -->\r\n\r\n## Context\r\n<!--- How has this issue affected you? What are you trying to accomplish? -->\r\n<!--- Providing context helps us come up with a solution that is most useful in the real world -->\r\n\r\n## Your Environment\r\n<!--- Include as many relevant details about the environment where the bug was discovered -->\r\n* AWSSDK.Core version used: 3.3.7\r\n* Service assembly and version used: \r\n* Operating System and version: Ubuntu 16.04\r\n* Visual Studio version: Visual Studio Code 1.13.1\r\n* Targeted .NET platform: netcoreapp1.1\r\n\r\n## .NET Core Info\r\n<!--- For .NET Core issues, please provide the following -->\r\n* .NET Core version used for development: 1.0.4\r\n* .NET Core version installed in the environment where application runs: 1.0.4\r\n* Output of `dotnet --info`: \r\n.NET Command Line Tools (1.0.4)\r\n\r\nProduct Information:\r\n Version:            1.0.4\r\n Commit SHA-1 hash:  af1e6684fd\r\n\r\nRuntime Environment:\r\n OS Name:     ubuntu\r\n OS Version:  16.04\r\n OS Platform: Linux\r\n RID:         ubuntu.16.04-x64\r\n Base Path:   /usr/share/dotnet/sdk/1.0.4\r\n* Contents of project.json/project.csproj: \r\n```xml\r\n<Project Sdk=\"Microsoft.NET.Sdk.Web\">\r\n  <PropertyGroup>\r\n    <TargetFramework>netcoreapp1.1</TargetFramework>\r\n  </PropertyGroup>\r\n  <ItemGroup>\r\n    <PackageReference Include=\"Microsoft.AspNetCore\" Version=\"1.1.1\" />\r\n    <PackageReference Include=\"Microsoft.AspNetCore.Mvc\" Version=\"1.1.2\" />\r\n    <PackageReference Include=\"Microsoft.AspNetCore.StaticFiles\" Version=\"1.1.1\" />\r\n    <PackageReference Include=\"Microsoft.Extensions.Logging.Debug\" Version=\"1.1.1\" />\r\n    <PackageReference Include=\"Microsoft.VisualStudio.Web.BrowserLink\" Version=\"1.1.0\" />\r\n    <PackageReference Include=\"AWSSDK.Extensions.NETCore.Setup\" Version=\"3.3.1\" />\r\n    <PackageReference Include=\"AWSSDK.S3\" Version=\"3.3.7\" />\r\n    <PackageReference Include=\"AWSSDK.ElasticTranscoder\" Version=\"3.3.1.14\" />\r\n    <PackageReference Include=\"AWSSDK.SimpleNotificationService\" Version=\"3.3.0.17\" />\r\n    <PackageReference Include=\"Newtonsoft.Json\" Version=\"10.0.2\" />\r\n    <PackageReference Include=\"RavenDB.Client\" Version=\"4.0.0-beta-40015\" />\r\n    <PackageReference Include=\"Microsoft.AspNetCore.WebSockets\" Version=\"1.0.2\" />\r\n    <PackageReference Include=\"WebSocketManager\" Version=\"1.0.1\" />\r\n    <PackageReference Include=\"Docker.DotNet\" Version=\"2.124.3\" />\r\n    <DotNetCliToolReference Include=\"Microsoft.DotNet.Watcher.Tools\" Version=\"1.0.0\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <Content Include=\"../dist/**/*.*\">\r\n      <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>\r\n      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>\r\n    </Content>\r\n  </ItemGroup>\r\n</Project>\r\n```\r\n[logging]: http://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/net-dg-config-other.html"}}
{"actor":{"display_login":"marcuslindblom"}}