Skip to content

Fixes #39143: reject zero-step cron expressions across all cron fields in the ScheduleInterval validator - #39180

Merged
harshach merged 1 commit into
mainfrom
detail/bug-fix/fixes-39143-reject-zero-step-cron-expressions-acro-41f647
Nov 28, 2026
Merged

harshach merged 1 commit into
mainfrom
detail/bug-fix/fixes-39143-reject-zero-step-cron-expressions-acro-41f647

Conversation

@detail-app

@detail-app detail-app Bot commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Detail bug report: View on Detail

Describe your changes:

Fixes #39143

I worked on the shared ScheduleInterval cron validator because it accepted cron expressions with a zero step (*/0, 1-5/0, 5/0, 1,2/0) in the hour, day-of-month, month, and day-of-week fields. The only step-aware guard (hasMultipleRunsPerHour) inspected the minute field alone, and the shared field regexes (Schedular.constants.ts) allow \/\d+ which matches /0. An invalid cron typed into a custom schedule therefore passed UI validation and was submitted to the backend, where it failed opaquely: an HTTP 500 (UNHANDLED_SERVER_EXCEPTION, "Failed in scheduling Job for the Application") on application install/update, and a permanently unscheduled, error-looping CronOMJob on the k8s operator (IllegalArgumentException: Failed to parse cron expression. Period 0 not in range [1, 31]). The legacy ingestion-wizard flow was unaffected because its cronValidator additionally runs cronstrue.toString, which rejects zero steps; the regression was introduced when PR #32082 rewired the app and test-suite-pipeline flows onto the regex-only validateCronExpression and demoted cronstrue to descriptive-only text.

The fix adds a small hasZeroStep(field) helper (same style as the existing hasDescendingMinuteRange/hasMultipleRunsPerHour) and a loop in validateCronExpression that applies it to all five cron fields right after the regex pattern loop, returning the offending field's error key. This restores the zero-step safety net cronstrue provided before #32082, covers the test-case-scheduling and bundle-suite flows (which never had it), and keeps the format-before-semantic ordering across fields.

Type of change:

  • Bug fix

High-level design:

N/A — small change. A single centralized zero-step check over all five fields was chosen over tightening each field regex in Schedular.constants.ts (\/\d+ → \/[1-9]\d*): both fix validateCronExpression, but the regex route depends on every future field-pattern edit remembering the [1-9] guard, while a dedicated helper keeps the invariant local to the validator and matches the existing step-aware pattern (hasMultipleRunsPerHour). The legacy cronValidator path is left untouched since cronstrue already gates it.

Tests:

Use cases covered

  • A zero step in any of minute/hour/day-of-month/month/day-of-week is rejected at form time with the offending field's error, so the invalid schedule is never submitted to the backend (covers */0, range 1-5/0, single 5/0, list 1,2/0, and leading-zero */00 variants)
  • Valid non-zero-step crons in every field (*/2, 1-5/2, 1,15/2, 1/2) are still accepted — no false-positive regression
  • Field-format errors (e.g. out-of-range month) are still reported before a zero-step error in an earlier field
  • Existing validations are unchanged: wrong field count, out-of-range values, descending minute ranges, and sub-hour frequency rejection

Unit tests

  • Files updated: openmetadata-ui/.../Steps/ScheduleInterval.utils.test.ts — 18 new cases (10 zero-step rejections across all fields/variants, 7 valid non-zero-step acceptances, 1 format-before-semantic ordering). 28 tests pass.

Backend integration tests

  • Not applicable (no backend API changes). The backend performs no cron validation of its own (verified live); the fix is entirely in the UI validator.

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Files updated: openmetadata-ui/.../playwright/e2e/Features/CronValidations.spec.ts — extended the existing Cron Validations spec with assertions that each zero-step cron (0 0 */0 * *, 0 0 * * */0, 0 */0 * * *, 0 0 1 */0 *, */0 0 * * *) renders the offending field's inline error in the real app-schedule form, and that a valid 0 0 */2 * * clears it. The full spec passes against a live stack (auth setup, entity seeding, and the cron validation scenario).

Manual testing performed

  1. Brought up a local stack (MySQL 8.4 + Elasticsearch 9.3 in Docker, the openmetadata-service jar against them, and the Vite dev server proxying /api to it) and ran the Cron Validations Playwright spec end-to-end (3/3 green, including the new zero-step assertions in a real browser).
  2. Against the live server, confirmed the happy path: PATCH /api/v1/apps/{id} with cronExpression: "0 0 */2 * *" returns HTTP 200 and persists.
  3. Reproduced the exact downstream failure the fix prevents: the same PATCH with cronExpression: "0 0 */0 * *" returns HTTP 500 UNHANDLED_SERVER_EXCEPTION "Failed in scheduling Job for the Application", with the server log showing IllegalArgumentException: Failed to parse cron expression. Period 0 not in range [1, 31] — matching the bug report. The UI fix blocks this cron at form time so the request can no longer be made from the UI.
  4. Unit tests (28/28), the broader ScheduleInterval + AddIngestion + AppInstall + AppSchedule + BundleSuite + TestSuitePipeline + TestCase suites (234/234 across 21 suites), TypeScript tsc:check (no new errors; baseline-identical when stashed), and ESLint/Prettier/organize-imports on all changed files all pass.

UI screen recording:

Not applicable — a form-validation correctness fix with no new UI surface or behavior to record (the change makes an existing error state appear for previously-accepted invalid input).

Checklist:

  • I have read CONTRIBUTING.md and the contributor docs.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed. (N/A — no schema changes.)
  • For UI changes: as part of PR creation, I ran the PR build in Docker with sample data and embedded a verified GitHub-hosted recording plus build/health evidence above, or explained why this requirement is not applicable. (N/A — validation fix with no new UI surface.)
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • Self-review: I reviewed the final diff against REVIEW.md and fixed every 🔴 finding, or answered it on the line below.
  • Decision check: if this PR decides something the next contributor could undo — a schema field, REST path or format another component or repo must agree with, a new default or limit, an ordering that must hold, or a rule stated only in this description — it adds a record under docs/decisions/. (N/A — the fix restores a pre-refactor(ui): consolidate schedule interval #32082 invariant rather than introducing a new decision.)
  • I have added a test that covers the exact scenario we are fixing.

Automatic Fixes PRs can be configured here.

@detail-app
detail-app Bot requested a review from a team as a code owner November 28, 2026 03:19
@harshach
harshach merged commit 6dd3866 into main Nov 28, 2026
42 of 43 checks passed
@harshach
harshach deleted the detail/bug-fix/fixes-39143-reject-zero-step-cron-expressions-acro-41f647 branch November 28, 2026 05:34
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.

[Detail Bug] Scheduling UI accepts cron expressions with zero step in non-minute fields, causing downstream scheduling failures

2 participants