Skip to content

fix(service): validate cron schedule before create_cron_job API call - #34

Open
aniruddhaadak80 wants to merge 1 commit into
render-oss:mainfrom
aniruddhaadak80:fix/cron-schedule-validation
Open

aniruddhaadak80 wants to merge 1 commit into
render-oss:mainfrom
aniruddhaadak80:fix/cron-schedule-validation

Conversation

@aniruddhaadak80

Copy link
Copy Markdown

What changed

  • Added validate.CronSchedule covering the 5-field standard cron format (minute 0-59, hour 0-23, day-of-month 1-31, month 1-12, day-of-week 0-7) with wildcards, ranges, steps, lists, JAN-DEC and SUN-SAT names.
  • createValidatedCronJobRequest now rejects invalid schedules locally with a clear invalid schedule expression error naming the bad field.
  • Added TestCronSchedule (9 valid, 12 invalid) plus TestCreateCronJobScheduleValidation wiring the validator into the request builder.

Why

create_cron_job accepted any schedule string and forwarded it to the Render API, so a typo like everyday or 99 99 * * * only failed downstream as an opaque API error. Local validation fails fast with the expected 5-field format hint.

Repro (before fix): createValidatedCronJobRequest with schedule everyday returned no error and proceeded to the API call. After fix it returns invalid schedule expression.

How tested

  • go test ./pkg/validate -count=1 -v (TestCronSchedule 21/21 pass)
  • go test ./pkg/service -run TestCreateCronJobScheduleValidation|TestCreateServiceRuntimeValidation|TestCreateCronJobTool -v (all pass)
  • go vet ./pkg/validate ./pkg/service clean
  • go build ./... clean

Fixes #31

create_cron_job forwarded any schedule string to the Render API, so typos
like everyday surfaced as opaque downstream errors. Validate the 5-field
expression locally (ranges, wildcards, ranges, steps, lists, JAN-DEC and
SUN-SAT names) and return a clear tool error naming the bad field.

Fixes render-oss#31

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

create_cron_job accepts invalid schedule expressions, surfacing opaque API errors

1 participant