Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws-lambda: function description length is not validated #20475

Closed
Gtofig opened this issue May 24, 2022 · 2 comments · Fixed by #20476
Closed

aws-lambda: function description length is not validated #20475

Gtofig opened this issue May 24, 2022 · 2 comments · Fixed by #20476
Labels
@aws-cdk/aws-lambda Related to AWS Lambda effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2

Comments

@Gtofig
Copy link
Contributor

Gtofig commented May 24, 2022

Describe the bug

Lambda function description has length limit of 256 characters, but it is not currently validated by CDK

Expected Behavior

Lambda function description length should be validated at build time and build should fail if length is above 256 char limit

Current Behavior

Lambda function description length is not validated and issue will be caught at deployment time

Reproduction Steps

    const stack = new cdk.Stack();
    new lambda.Function(stack, 'MyFunction', {
      code: lambda.Code.fromInline('foo'),
      runtime: lambda.Runtime.NODEJS_14_X,
      handler: 'index.handler',
      description: 'a'.repeat(257),
    });

Possible Solution

Validate description length:

    if (props.description && !Token.isUnresolved(props.description)) {
      if (props.description.length > 256) {
        throw new Error(`Function description can not be longer than 256 characters but has ${props.description.length} characters.`);
      }
    }

Additional Information/Context

No response

CDK CLI Version

2.21.1

Framework Version

No response

Node.js Version

v14.19.1

OS

Ubuntu 20

Language

Typescript

Language Version

3.8.3

Other information

No response

@Gtofig Gtofig added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 24, 2022
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label May 24, 2022
@Gtofig
Copy link
Contributor Author

Gtofig commented May 24, 2022

Submitted a PR with a fix: #20476

@kaizencc kaizencc added p2 feature-request A feature should be added or improved. and removed needs-triage This issue or PR still needs to be triaged. bug This issue is a bug. labels May 24, 2022
@kaizencc kaizencc removed their assignment May 24, 2022
@kaizencc kaizencc added the effort/small Small work item – less than a day of effort label May 24, 2022
@mergify mergify bot closed this as completed in #20476 May 24, 2022
mergify bot pushed a commit that referenced this issue May 24, 2022
closes #20475.

----

### All Submissions:

* [X] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda Related to AWS Lambda effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants