aws-lambda-dotnet icon indicating copy to clipboard operation
aws-lambda-dotnet copied to clipboard

Add validation during build time for Handler max length

Open matthewyost opened this issue 1 year ago • 4 comments

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

  • [ ] I may be able to implement this feature request
  • [ ] This feature might incur a breaking change

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

matthewyost avatar Jul 18 '24 15:07 matthewyost

Hi @matthewyost,

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

Regards, Chaitanya

bhoradc avatar Jul 18 '24 15:07 bhoradc

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.

ashishdhingra avatar Jul 18 '24 16:07 ashishdhingra

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 avatar Jul 18 '24 16:07 matthewyost

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.

ashishdhingra avatar Jul 18 '24 17:07 ashishdhingra

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

96malhar avatar Sep 27 '24 21:09 96malhar