aws / aws-lambda-dotnet

Libraries, samples and tools to help .NET Core developers develop AWS Lambda functions.
Apache License 2.0
1.57k stars 479 forks source link

When a dotnet lambda zip package contains more than 1 .deps file, the error printed is misleading #1430

Open rpgeddam opened 1 year ago

rpgeddam commented 1 year ago

Describe the bug

https://github.com/aws/aws-lambda-dotnet/blob/48ea41ecc61136390d62a26ca41d41fa3a4d9e66/Libraries/src/Amazon.Lambda.RuntimeSupport/bootstrap.sh#L73-L74

This bit of code looks for a <assemblyname>.deps file. If that file does not exist it looks for *.deps files. If it finds more than 1 matching file, it fails with the error message:

The ${LAMBDA_TASK_ROOT} directory is missing the required .deps.json file.

which is slightly misleading.

Expected Behavior

A better error message that indicates that more *.deps files than expected were encoutered.

Current Behavior

A wrong error message that says there were no *.deps files

Reproduction Steps

Add an extra *.deps file to working lambda zip package and deploy it.

Possible Solution

No response

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

AWSSDK.Core 3.5.3.3

Targeted .NET Platform

.NET 6

Operating System and version

Amazon Lambda

ashishdhingra commented 1 year ago

@rpgeddam Could you please elaborate the reproduction steps Add an extra *.deps file to working lambda zip package and deploy it. and share the sample code solution to reproduce the issue? Are you manually adding the .dep file(s)?

Thanks, Ashish

rpgeddam commented 1 year ago

We have an internal project that produced a zip file with two .deps files upon running :

dotnet lambda package --output-package foo.zip --configuration Release --framework net6.0

When this zip was deployed to AWS Lambda, we saw the error:

Error: .NET binaries for Lambda function are not correctly installed in the /var/task directory of the image when the image was built. The /var/task directory is missing the required .deps.json file.

Which lead us down dead-end thinking that the lambda runtime was somehow unable to find the .deps files. Eventually after locating the code linked to in the original post, we manually deleted one .deps file, re-packaged the zip and deployed it, which gave us a working lambda. We likely would've zeroed in on the fact that two .deps files was causing the issue if the error message was a bit more specific, hence this issue.

We haven't yet figured out why dotnet lambda package produces a zip with two .deps files.

I cannot share our project code, but will attempt to create a minimal verifiable example - but that may depend on us figuring out the packaging issue first.

rpgeddam commented 1 year ago

This issue contains an example that reproduces the issue in this thread. Please note that the the two issues aren't exactly duplicates, because this one is asking to clarify the error message to make troubleshooting easier.

also related: https://github.com/aws/aws-lambda-dotnet/issues/1235

thelok commented 3 weeks ago

We also ran into this issue. We have a C# lambda project that references other projects. It so happens that there's a 2nd project that also produces *.deps.json and *.runtimeconfig.json files. Deleting the other *.deps.json and *.runtimeconfig.json files ends up working but the error messages are definitely misleading.