Closed Kuling closed 5 months ago
Thanks for opening your first issue here! We'll come back to you as soon as we can. In the meantime, check out the #dotnet channel on our Powertools for AWS Lambda Discord: Invite link
Hey @Kuling thanks for raising an issue. I was able to reproduce the issue and working on a fix as we speak. Will let you know once we are ready to push the fix.
@Kuling pull request created #572 will try to release this week. Also looking at your code above it works but please decorate the methods and not the classes.
@Kuling Tracing 1.4.2 released with the fix https://www.nuget.org/packages/AWS.Lambda.Powertools.Tracing/1.4.2 Let us know if it works as expected
Good morning @hjgraca I can confirm that 1.4.2 works without issues. Thank you very much for your help.
Expected Behaviour
Call of generic method shouldn't fail.
Current Behaviour
Following exception was thrown.
System.InvalidCastException HResult=0x80004002 Message=Unable to cast object of type 'System.Threading.Tasks.Task
1[System.Double]' to type 'System.Threading.Tasks.Task
1[System.Int32]'. Source=REDACTED StackTrace: at MyFunction.SampleService.LoadAsync[T](T query) in C:\src\REDACTED\Function.cs:line 19This exception was originally thrown at this call stack: MyFunction.SampleService.LoadAsync(T) in Function.cs
Code snippet
Possible Solution
No response
Steps to Reproduce
Run above lambda. On the line marked with comment "// Bug" you will encounter System.InvalidCastException. This exception happens only when [Tracing] flag is added.
I believe library somehow improperly cached return type (Task) from first invocation.
And then used it in second invocation.
Powertools for AWS Lambda (.NET) version
1.4.1
AWS Lambda function runtime
dotnet6
Debugging logs
No response