aws / aws-lambda-dotnet

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

Add validation during build time for Handler max length #1778

Closed matthewyost closed 2 months ago

matthewyost commented 4 months ago

Describe the feature

Include validation on the LambdaFunction attribute that notifies developer that the generated function handler is over the maximum character length (128) so that it can be fixed at build time.

Use Case

When using the Amazon.Lambda.Annotations you can hit the limit for max length of a FunctionHandler string in Cloudformation and only recognize this after attempting to deploy it

Proposed Solution

No response

Other Information

No response

Acknowledgements

AWS .NET SDK and/or Package version used

Amazon.Lambda.Annotations version 1.5.0.0

Targeted .NET Platform

.NET 6/8

Operating System and version

All

bhoradc commented 4 months ago

Hi @matthewyost,

Thanks for submitting the feature request. I will review it with the team.

Regards, Chaitanya

ashishdhingra commented 4 months ago

Also refer https://github.com/aws/aws-lambda-dotnet/issues/1642 where the last character is stripped from the handler name. It's an open issue with the Lambda runtime team and they might plan to fix it in near future. So, currently, handler name of 127 would be supported actually due to issue in runtime.

matthewyost commented 4 months ago

While I understand that there is a boundary concern here (still valid), the request is more for the DevX around finding this in the IDE before we execute it in CloudFormation. I spent a lot of time trying to determine exactly why this was happening only to figure out that it was being cause by the SourceGenerator inside the Annotations library.

If we had the ability to have this lintable, that would be ideal.

ashishdhingra commented 4 months ago

While I understand that there is a boundary concern here (still valid), the request is more for the DevX around finding this in the IDE before we execute it in CloudFormation. I spent a lot of time trying to determine exactly why this was happening only to figure out that it was being cause by the SourceGenerator inside the Annotations library.

If we had the ability to have this lintable, that would be ideal.

@matthewyost Thanks for your reply. I added https://github.com/aws/aws-lambda-dotnet/issues/1778#issuecomment-2237014066 just for reference. It would still be a good idea to add some validation.

96malhar commented 2 months ago

Hello! We have added a new validator that checks and imposes a character limit on the Lambda function handler. See PR #1812. This change was released in Amazon.Lambda.Annotations v1.5.1