8000 Changed: adjust validation for scheduler expression by anisaoshafi · Pull Request #12220 · localstack/localstack · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Changed: adjust validation for scheduler expression #12220

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

Merged
merged 1 commit into from
Feb 3, 2025

Conversation

anisaoshafi
Copy link
Contributor

Motivation

Before, the eventbridge scheduler passed no validation at all since all of the logic was defaulting to moto's logic.

We added some validation few days ago, however, seems like the rule for at() syntax for scheduled-expression was too limited, since the validation fails on localstack, but succeeds on aws.

This caused a blocker for this user: #12191 (comment).

Changes

Adjusted validation rule for schedule_expression with at() syntax.
Added a test to check the syntax works.

Copy link
github-actions bot commented Feb 3, 2025

LocalStack Community integration with Pro

 2 files   2 suites   21s ⏱️
23 tests 21 ✅ 2 💤 0 ❌
25 runs  21 ✅ 4 💤 0 ❌

Results for commit 3e1bbfb.

@anisaoshafi anisaoshafi added aws:events Amazon EventBridge semver: patch Non-breaking changes which can be included in patch releases labels Feb 3, 2025
@anisaoshafi anisaoshafi added this to the 4.2 milestone Feb 3, 2025
@anisaoshafi anisaoshafi self-assigned this Feb 3, 2025
Copy link
Contributor
@bentsku bentsku left a comment

Choose a reason for hiding this comment

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

LGTM! I just have a small question, but this good to be merged to unblock the users! 🚀 thanks for jumping on this 🙏

Comment on lines +13 to +15
AT_REGEX = (
r"^at[(](19|20)\d\d-(0[1-9]|1[012])-([012]\d|3[01])T([01]\d|2[0-3]):([0-5]\d):([0-5]\d)[)]$"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

question: how was the previous regex rule created, and how does the new one differ? How are we sure this is the right format, is there documentation online? Sorry, I don't know Scheduler so well and I wondered if there was any documentation or anything that helped you create this regex. Thanks! 🙏

Copy link
Contributor Author
@anisaoshafi anisaoshafi Feb 3, 2025

Choose a reason for hiding this comment

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

We didn't have any test for what a correct schedule creation should look like.
Before, anything was allowed in scheduler because moto wasn't validating it.
I don't properly remember where I copied it from, sorry (stackoverflow or else), but apparently I didn't test the condition for at, I just tested the invalid ones, but not a valid one, and that ended up blocking a user.

I should have added this test tests_create_schedule_with_valid_schedule_expression since that PR that introduced the validation for scheduler, but I struggled making a it work against aws.
This time I took the time to fix it, and turns out the issue I was getting was because the IAM role takes some time to propagate and because of that I was getting some permission issue for the scheduler. So we just have to wait some seconds for is_aws_cloud.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the aws docs for this.

@anisaoshafi anisaoshafi merged commit dd330d3 into master Feb 3, 2025
35 of 36 checks passed
@anisaoshafi anisaoshafi deleted the fix-scheduler-at-regex branch February 3, 2025 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws:events Amazon EventBridge semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0