Repository navigation
Description
Describe the bug
When I'm running some code in the test tool, I come across an issue, when System.Text.Json.JsonSerializer.Deserialize returns different results depending on whether it's being called from the top level or from a System.ComponentModel.TypeConverter method.
This is best illustrated with code (see attachment)
Run:
dotnet tool restore
dotnet build
dotnet dotnet-lambda-test-tool-6.0 --no-ui --function-handler Lambda::Main.Lambda::Handler --pause-exit false
Output:
AWS .NET Core 6.0 Mock Lambda Test Tool (0.12.7)
Loaded local Lambda runtime from project output /home/alex.bolenok/Projects/lambda-test-tool/bin/Debug/net6.0
Executing Lambda function without web interface
... Using function handler Lambda::Main.Lambda::Handler
... No payload configured. If a payload is required set the --payload switch to a file path or a JSON document.
... Setting AWS_PROFILE environment variable to default.
... No default AWS region configured. The --region switch can be used to configure an AWS Region.
Captured Log information:
test
True
Main.S3Bucket
Main.S3Bucket
>>>> False <<<<
Request executed successfully
Response:
This issue seems to be specific to the test tool (when I run this code in an actual Lambda, or in a console app, it works as expected).
Expected Behavior
TypeDescriptor.GetConverter(typeof T).ConvertFrom and JsonSerializer.Deserialize<T> both return objects of the same type T.
Current Behavior
TypeDescriptor.GetConverter(typeof T).ConvertFrom and JsonSerializer.Deserialize<T> return objects of different types.
Reproduction Steps
Run:
dotnet tool restore
dotnet build
dotnet dotnet-lambda-test-tool-6.0 --no-ui --function-handler Lambda::Main.Lambda::Handler --pause-exit false
Output:
AWS .NET Core 6.0 Mock Lambda Test Tool (0.12.7)
Loaded local Lambda runtime from project output /home/alex.bolenok/Projects/lambda-test-tool/bin/Debug/net6.0
Executing Lambda function without web interface
... Using function handler Lambda::Main.Lambda::Handler
... No payload configured. If a payload is required set the --payload switch to a file path or a JSON document.
... Setting AWS_PROFILE environment variable to default.
... No default AWS region configured. The --region switch can be used to configure an AWS Region.
Captured Log information:
test
True
Main.S3Bucket
Main.S3Bucket
>>>> False <<<<
Request executed successfully
Response:
Possible Solution
There is something weird in the way the test tool calles the framework methods. The actual lambda runtime works fine.
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
{
"version": 1,
"isRoot": true,
"tools": {
"amazon.lambda.testtool-6.0": {
"version": "0.12.7",
"commands": [
"dotnet-lambda-test-tool-6.0"
]
}
}
}
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.1" />
<PackageReference Include="Amazon.Lambda.SQSEvents" Version="2.1.0" />
Targeted .NET Platform
.NET 6
Operating System and version
Amazon Linux
Activity
[-]JsonSerializer.Deserialize<T> returns invalid object when called by TypeConverter within AWS Lambda Test Tool(short issue description)[/-][+]JsonSerializer.Deserialize<T> returns invalid object when called by TypeConverter within AWS Lambda Test Tool[/+]ashishdhingra commentedon Mar 13, 2023
Reproducible using below code in test tool (code is ported to Lambda project type for easy debugging):
.csproj
Function.cs
While executing under Lambda Test tool, the statement
(s3BucketFails is S3Bucket).ToString()returnsFalse. Executing the same statement in immediate window when breakpoint is hit during debugging using Lambda Test tool returns correct value ofTrue.ashishdhingra commentedon Nov 5, 2024
Reproducible in latest Lambda .NET Empty function blueprint.
.csproj
Function.cs
Lambda Test Tool Execution log
Lambda environment execution log
If we look at Lambda Test tool execution log,
LambdaNet8Testassembly is loaded twice. It could be the reason on whyConsole.WriteLine((s3BucketFails is S3Bucket).ToString());is returning inconsistent result as compared to actual Lambda environment.quassnoi commentedon Mar 18, 2026
@ashishdhingra still reproduces on .NET 10 with
amazon.lambda.testtool-10.0.Any plans to fix it?
dscpinheiro commentedon Oct 20, 2026
This does not occur on the new Amazon.Lambda.TestTool, which runs the function out of process. Please use that tool going forward.
github-actions commentedon Oct 20, 2026
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.