System.ArgumentException running with .NET 7 NativeAOT #1425
-
I'm trying to run the attached sample project with the .NET 7 test tool. I input "{"Id": "test"} in the Tool. I expected it to detect it as a "Test" object and return "test" as an uppercase string. However, I'm getting an ArgumentException because it says it can't convert a memory stream to an APIGatewayHttpApiV2ProxyRequest. I don't understand how to test my function? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
@fiannafritz Good afternoon. The issue doesn't appear to be reproducible in the actual AWS environment while deploying the code to
{
"version": "2.0",
"routeKey": "$default",
"rawPath": "/my/path",
"rawQueryString": "parameter1=value1¶meter1=value2¶meter2=value",
"cookies": [
"cookie1",
"cookie2"
],
"headers": {
"header1": "value1",
"header2": "value1,value2"
},
"queryStringParameters": {
"parameter1": "value1,value2",
"parameter2": "value"
},
"requestContext": {
"accountId": "123456789012",
"apiId": "api-id",
"authentication": {
"clientCert": {
"clientCertPem": "CERT_CONTENT",
"subjectDN": "www.example.com",
"issuerDN": "Example issuer",
"serialNumber": "a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1",
"validity": {
"notBefore": "May 28 12:30:02 2019 GMT",
"notAfter": "Aug 5 09:36:04 2021 GMT"
}
}
},
"authorizer": {
"jwt": {
"claims": {
"claim1": "value1",
"claim2": "value2"
},
"scopes": [
"scope1",
"scope2"
]
}
},
"domainName": "id.execute-api.us-east-1.amazonaws.com",
"domainPrefix": "id",
"http": {
"method": "POST",
"path": "/my/path",
"protocol": "HTTP/1.1",
"sourceIp": "192.0.2.1",
"userAgent": "agent"
},
"requestId": "id",
"routeKey": "$default",
"stage": "$default",
"time": "12/Mar/2020:19:03:58 +0000",
"timeEpoch": 1583348638390
},
"body": "{\"Id\": \"Hello from Lambda\"}",
"pathParameters": {
"parameter1": "value1"
},
"isBase64Encoded": false,
"stageVariables": {
"stageVariable1": "value1",
"stageVariable2": "value2"
}
} Kindly note that the However, in Lambda Test Tool, it's giving the error CCing @normj. EDIT 1: I found similar error reported in StackOverflow post https://stackoverflow.com/questions/75276346/testing-nativeaot-with-mock-lambda-test-tool-results-in-error and it suggested to use EDIT 2: I was able to run it successfully using the below steps:
{
"profiles": {
"MyFirstLambdaVS2022": {
"commandName": "Project",
"environmentVariables": {
"AWS_LAMBDA_RUNTIME_API": "localhost:5050"
}
}
}
} Take note that the
|
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
@fiannafritz Good afternoon. The issue doesn't appear to be reproducible in the actual AWS environment while deploying the code to
us-east-2
region:aws-lambda-tools-defaults.json
to use regionus-east-2
.dotnet lambda deploy-function
to deploy the function to AWS.