Skip to content

Fix cron validation against the scheduler parser - #13556

Merged
HarshMN2345 merged 6 commits into
mainfrom
codex/sentry-cron-validation
Sep 9, 2026
Merged

HarshMN2345 merged 6 commits into
mainfrom
codex/sentry-cron-validation

Conversation

@HarshMN2345

@HarshMN2345 HarshMN2345 commented Sep 9, 2026 •

Copy link
Copy Markdown
Member

Function schedule validation used a different parser from the scheduler. A mixed field such as 0 22-3,5 * * * passed API validation because its valid list member produced a next date, then failed every scheduler reconciliation when the runtime rejected the descending range.

Validate accepted cron syntax with Utopia\Schedule\Trigger\Cron, which also rejects impossible dates. Function creation and updates now reject expressions the scheduler cannot execute. Valid overnight ranges such as 22-23,0-3 retain their execution times, and rejected updates preserve the existing schedule.

Validation:

  • Five regression cases failed before the fix and pass afterward (one per cron field).
  • Cron validator unit tests: 6 tests, 13 assertions.
  • Real FunctionsSchedule API tests: 4 tests, 28 assertions, on an isolated API container using this branch. Both plain 0 22-3 * * * and mixed 0 22-3,5 * * * expressions are rejected on creation and update; rejected updates preserve the valid stored schedule.
  • Focused PHPStan, Pint, Rector and git diff --check pass.

Existing malformed schedule rows still need their intended expression corrected; this change does not reinterpret customer schedules.

Fixes CLOUD-3QW1.

@greptile-apps

greptile-apps Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge with no outstanding correctness, security, or repository-rule violations.

Summary

  • Replaces occurrence-based validation with construction of the scheduler’s cron trigger.
  • Adds unit coverage for descending ranges embedded in every cron field.
  • Adds API coverage confirming invalid creates and updates are rejected and failed updates preserve the existing schedule.
  • Extends the API cases since the previous review to cover both plain and list-embedded descending ranges.
  • The previously reported implementation-coupled occurrence-expansion test has been removed.

Comment thread tests/unit/Task/Validator/CronTest.php Resolved
@github-actions

github-actions Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → codex/sentry-cron-validation (after).

Metric Before After Change
🚀 Requests/sec 275.07 254.09 🔴 -7.6%
⏱️ Latency P50 63.62 ms 69.36 ms 🔴 +9%
⏱️ Latency P95 147.41 ms 161.91 ms 🔴 +9.8%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 69.36 161.91 15,960 254.09 +14.5
Account 138.08 231.94 840 14.07 -4.71
TablesDB 66.53 119.45 8,680 141.64 +7.75
Storage 64.93 137.3 4,200 70.12 +9.72
Functions 104.96 194.4 2,240 38.06 +18.97

Top API waits (after)

API request Max wait (ms)
account.prefs.update 353.17
account.name.update 304.31
functions.delete 285.38
functions.create 284.31
tablesdb.rows.create 267.49

'functionId' => ID::unique(),
'name' => 'Invalid schedule',
'runtime' => 'node-22',
'schedule' => '0 22-3,5 * * *',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We didnt heck for Sentry error, whihc is 22-3

@HarshMN2345
HarshMN2345 merged commit c230bcb into main Sep 9, 2026
45 checks passed
@ChiragAgg5k ChiragAgg5k mentioned this pull request Sep 10, 2026
2 of 4 tasks
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.

3 participants