fix(scheduler): treat cron weekday 7 as Sunday#6090
Open
TowyTowy wants to merge 1 commit into
Open
Conversation
Cron expressions accept both 0 and 7 for Sunday, and ParseCronExpression already validates weekday values across the 0-7 range. But matches() compared the field against time.Weekday, which only ranges 0 (Sunday) to 6 (Saturday) and never returns 7, so a schedule written with 7 (e.g. "0 0 * * 7") never fired on Sundays. Also test the weekday matcher against 7 when the day is Sunday. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughCron weekday matching now recognizes both ChangesCron weekday matching
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cron expressions accept both
0and7for Sunday, andParseCronExpressionalready validates weekday values across the documented0-7range (8is rejected). However,Schedule.matchescompared the weekday field againsttime.Weekday, which only ranges 0 (Sunday) to 6 (Saturday) and never returns 7 — so a schedule written with7(e.g.0 0 * * 7) never fired on Sundays.This checks the weekday matcher against
7as well when the day is Sunday, so both spellings behave identically. The change is additive for the Sunday case and leaves all other weekdays untouched. It works across all field types (exact, range like5-7, list, step, wildcard).Test:
TestScheduleWeekdaySevenIsSundayasserts0 0 1 * 7matches Sunday 2025-01-05 (not Monday the 6th) and thatNext(2025-01-02)returns the Jan 5 Sunday rather than skipping to Feb 1. Fails before, passes after;gofmt/go vetclean.Prepared with AI assistance (Claude) and reviewed/verified by me.