Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception in ErrorHandler.ProcessException() #858

Closed
xakep139 opened this issue Feb 6, 2018 · 8 comments
Closed

Exception in ErrorHandler.ProcessException() #858

xakep139 opened this issue Feb 6, 2018 · 8 comments
Assignees
Labels
bug This issue is a bug. module/sdk-core p2 This is a standard priority issue queued

Comments

@xakep139
Copy link

xakep139 commented Feb 6, 2018

If ErrorHandler get an exception of type System.Exception there will be a System.ArgumentNullException with message:

Value cannot be null.
Parameter name: key

Here's the stacktrace:

   at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
   at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
   at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
   at Amazon.Runtime.Internal.ErrorHandler.ProcessException(IExecutionContext executionContext, Exception exception) in E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\ErrorHandler\ErrorHandler.cs:line 200
   at Amazon.Runtime.Internal.ErrorHandler.<InvokeAsync>d__5`1.MoveNext() in E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\ErrorHandler\ErrorHandler.cs:line 104
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   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.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   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
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   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 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   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 153
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   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.ExceptionServices.ExceptionDispatchInfo.Throw()
   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.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Amazon.S3.Internal.AmazonS3ExceptionHandler.<InvokeAsync>d__1`1.MoveNext() in E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Services\S3\Custom\Internal\AmazonS3ExceptionHandler.cs:line 62
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   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
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   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.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at DemoS3.Program.<WritingAnObject>d__2.MoveNext() in C:\Users\n.balabaev\Documents\Visual Studio 2017\Projects\DemoS3\Program.cs:line 43

Expected Behavior

Get original exception from ErrorHandler

Current Behavior

Possible Solution

Fix loop logic in ErrorHandler.ProcessException() if exception has type System.Exception

Steps to Reproduce (for bugs)

I've created a repro https://github.com/xakep139/DemoS3. If you replace Exception with any of it subclass (here https://github.com/xakep139/DemoS3/blob/master/BrokenStream.cs#L14), the exception thrown at ErrorHandler.ProcessException() (https://github.com/aws/aws-sdk-net/blob/master/sdk/src/Core/Amazon.Runtime/Pipeline/ErrorHandler/ErrorHandler.cs#L187) will be correct.

Context

Your Environment

  • AWSSDK.Core version used: 3.3.21.6
  • Service assembly and version used: AWSSDK.S3 version 3.3.17
  • Operating System and version: Windows 10 Enterprise 1709 (16299.192)
  • Visual Studio version: Microsoft Visual Studio Professional 2017 Version 15.5.5
  • Targeted .NET platform: .NET Core 2.0

.NET Core Info

  • .NET Core version used for development: 2.0.5
  • .NET Core version installed in the environment where application runs: 2.0.5
  • Output of dotnet --info:
.NET Command Line Tools (2.1.4)

Product Information:
 Version:            2.1.4
 Commit SHA-1 hash:  5e8add2190

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.16299
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.4\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.5
  Build    : 17373eb129b3b05aa18ece963f8795d65ef8ea54
@sstevenkang sstevenkang self-assigned this Feb 19, 2018
@klaytaybai klaytaybai added the bug This issue is a bug. label Nov 18, 2019
@ashishdhingra ashishdhingra added needs-reproduction This issue needs reproduction. B module/sdk-core and removed needs-reproduction This issue needs reproduction. labels Oct 15, 2020
@github-actions
Copy link

We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Oct 16, 2021
@xakep139
Copy link
Author

@sstevenkang any chance this could be fixed?

@github-actions github-actions bot removed the closing-soon This issue will automatically close in 4 days unless further comments are made. label Oct 17, 2021
@github-actions
Copy link

We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Oct 17, 2022
@xakep139
Copy link
Author

@ashishdhingra do you have any estimations when this issue will be picked up for fixing?

@github-actions github-actions bot removed the closing-soon This issue will automatically close in 4 days unless further comments are made. label Oct 18, 2022
@ashishdhingra ashishdhingra added p2 This is a standard priority issue queued and removed B labels Nov 2, 2022
@cschulznethaus
Copy link

Stumbled on the same issue. I guess ErrorHandler.ProcessExceptionAsync() does not work well, when the exception that is handled is already of type Exception.

@ashishdhingra
Copy link
Contributor

Reproducible using code below:
BrokenStream.cs

namespace ConsoleTest
{
    public class BrokenStream : Stream
    {
        public override void Flush()
        {
        }

        public override int Read(byte[] buffer, int offset, int count)
        {
            throw new Exception("Oooops!");
        }

        public override long Seek(long offset, SeekOrigin origin)
        {
            throw new NotSupportedException();
        }

        public override void SetLength(long value)
        {
            throw new NotSupportedException();
        }

        public override void Write(byte[] buffer, int offset, int count)
        {
            throw new NotSupportedException();
        }

        public override bool CanRead => true;
        public override bool CanSeek => false;
        public override bool CanWrite => false;
        public override long Length => 123;
        public override long Position { get; set; }
    }
}

Program.cs

using Amazon.Runtime;
using Amazon.S3.Model;
using Amazon.S3;
using ConsoleTest;

const string BucketName = "somebucket";

using (var client = new AmazonS3Client())
{
    using (var myBrokenStream = new BrokenStream())
    {
        await WritingAnObject(client, myBrokenStream);
    }
}

static async Task WritingAnObject(IAmazonS3 client, Stream inputStream)
{
    try
    {
        var request = new PutObjectRequest
        {
            InputStream = inputStream,
            BucketName = BucketName,
            CannedACL = S3CannedACL.PublicRead,
            Key = "1/temp.txt"
        };

        await client.PutObjectAsync(request);
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex);
    }
}

@ashishdhingra
Copy link
Contributor

Fix has been released in AWSSDK.Core 3.7.400.1

Copy link

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. module/sdk-core p2 This is a standard priority issue queued
Projects
None yet
Development

No branches or pull requests

5 participants