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

feat(scheduler): validate schedule name length #31200

Merged

Conversation

LaurenceWarne
Copy link
Contributor

@LaurenceWarne LaurenceWarne commented Aug 23, 2024

Issue # (if applicable)

N/A

Reason for this change

To catch name too long errors before hitting Cloudformation.

Description of changes

I've added a length assertion in the Schedule constructor against the schedule name length, the documentation on schedule name already makes it clear that there is a limit though AFAICS this isn't validated.

Also see the Cloudformation doc here: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-name.

Description of how you validated changes

I've added a unit test.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added the p2 label Aug 23, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team August 23, 2024 12:27
@github-actions github-actions bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label Aug 23, 2024
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@LaurenceWarne
Copy link
Contributor Author

Exemption Request: not really sure how to cover this with an integration test - I thought a unit test might suffice for something this small?

@aws-cdk-automation aws-cdk-automation added pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Aug 23, 2024
Copy link
Contributor

@go-to-k go-to-k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I just made a few minor comments.

@@ -324,6 +324,9 @@ export class Schedule extends Resource implements ISchedule {
const flexibleTimeWindow = props.timeWindow ?? TimeWindow.off();

this.validateTimeFrame(props.start, props.end);
if (props.scheduleName && !Token.isUnresolved(props.scheduleName) && props.scheduleName.length > 64) {
throw new Error(`schedule name '${props.scheduleName}' exceeds 64 characters in length`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be user-friendly and good to display the length.

Suggested change
throw new Error(`schedule name '${props.scheduleName}' exceeds 64 characters in length`);
throw new Error(`scheduleName cannot be longer than 64 characters, got: ${props.scheduleName.length}`);

@@ -214,5 +214,16 @@ describe('Schedule', () => {
});
}).toThrow('The provided duration must be between 1 minute and 1440 minutes, got 0');
});

test('throw error when schedule name exceeds 64', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
test('throw error when schedule name exceeds 64', () => {
test('throw error when scheduleName exceeds 64 characters', () => {

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Aug 29, 2024
@go-to-k
Copy link
Contributor

go-to-k commented Aug 29, 2024

As this issue is not about a bug, the PR title may be good for chore.

@LaurenceWarne LaurenceWarne changed the title fix(scheduler): validate schedule name length chore(scheduler): validate schedule name length Aug 30, 2024
@LaurenceWarne
Copy link
Contributor Author

Thanks for the review, I've updated the title and made the requested changes.

@aws-cdk-automation aws-cdk-automation dismissed their stale review August 30, 2024 12:28

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

Copy link
Contributor

@go-to-k go-to-k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM.

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Aug 31, 2024
@kaizencc kaizencc changed the title chore(scheduler): validate schedule name length feat(scheduler): validate schedule name length Sep 4, 2024
@kaizencc kaizencc self-assigned this Sep 4, 2024
@kaizencc kaizencc added pr-linter/exempt-readme The PR linter will not require README changes pr-linter/exempt-integ-test The PR linter will not require integ test changes and removed pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. labels Sep 4, 2024
Copy link
Contributor

@kaizencc kaizencc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is technically a feat! validation is a feature of CDK so I think this counts. I also want this to show up in the changelog

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Sep 4, 2024
Copy link
Contributor

mergify bot commented Sep 4, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 887a1de
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit d0f9688 into aws:main Sep 4, 2024
9 checks passed
Copy link
Contributor

mergify bot commented Sep 4, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

Copy link

github-actions bot commented Sep 4, 2024

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/exempt-readme The PR linter will not require README changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants