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

Validate frequency of days #13

Open
kaushalnavneet opened this issue Feb 16, 2021 · 1 comment
Open

Validate frequency of days #13

kaushalnavneet opened this issue Feb 16, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@kaushalnavneet
Copy link

This issue is caught in a Timed Trigger type for a Tekton pipeline.
When I set the cron expression 0 8 */80 * * for a job and it shows At 08:00 AM, every 80 days there. But actually, there is no such cron expression that will work for every 80 days. The expression above means At 08:00 on every 80th day-of-month, but eventually, this job runs on the 1st of every month. We could probably add validation for such scenarios when the frequency of the day (or any other component) exceeds the maximum length.
We use cron-validator to validate the cron expression and it doesn't seem to consider it as an incorrect expression. If the frequency of the day (like in this example 80) exceeds the length of days of that month (28 or 30 or 31), it should not pass it as a valid expression because the actual frequency happens on the 1st day of the next month, not on every 80 days.
The code being used:

const cron = require("cron-validator");
cron.isValidCron(cronString, { alias: true });

Expected: cron.isValidCron(...) should return false when the frequency exceeds the maximum length.

Routed here based on the recommendation from cronstrue.

PS: Tested with the latest version, it doesn't seem to address this issue.

@GuillaumeRochat
Copy link
Owner

According the cron syntax spec, there is no limit to the steps values (aside from the divide by 0 you filed earlier), which I assume was to make it easier to parse at the time. I could add the limits though I don't have the time for this feature right away.

You could try out the cron-validate library for the time being, as they already have a way to specify limits I think (though not sure if they apply to steps).

@GuillaumeRochat GuillaumeRochat added the enhancement New feature or request label Feb 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants