Skip to content

fix(scheduler): treat cron weekday 7 as Sunday#6090

Open
TowyTowy wants to merge 1 commit into
usememos:mainfrom
TowyTowy:fix/cron-weekday-sunday
Open

fix(scheduler): treat cron weekday 7 as Sunday#6090
TowyTowy wants to merge 1 commit into
usememos:mainfrom
TowyTowy:fix/cron-weekday-sunday

Conversation

@TowyTowy

Copy link
Copy Markdown
Contributor

Cron expressions accept both 0 and 7 for Sunday, and ParseCronExpression already validates weekday values across the documented 0-7 range (8 is rejected). However, Schedule.matches compared the weekday 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.

This checks the weekday matcher against 7 as 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 like 5-7, list, step, wildcard).

Test: TestScheduleWeekdaySevenIsSunday asserts 0 0 1 * 7 matches Sunday 2025-01-05 (not Monday the 6th) and that Next(2025-01-02) returns the Jan 5 Sunday rather than skipping to Feb 1. Fails before, passes after; gofmt / go vet clean.

Prepared with AI assistance (Claude) and reviewed/verified by me.

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>
@TowyTowy
TowyTowy requested a review from a team as a code owner July 13, 2026 11:28
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e1232544-d13d-4dec-97c4-80923a597b02

📥 Commits

Reviewing files that changed from the base of the PR and between a9fcd45 and 0f09e40.

📒 Files selected for processing (2)
  • internal/scheduler/parser.go
  • internal/scheduler/parser_test.go

📝 Walkthrough

Walkthrough

Cron weekday matching now recognizes both 0 and 7 as Sunday, with regression tests covering direct schedule matching and the next scheduled occurrence.

Changes

Cron weekday matching

Layer / File(s) Summary
Weekday matching and regression coverage
internal/scheduler/parser.go, internal/scheduler/parser_test.go
Schedule.matches uses weekday-specific logic that supports cron weekday 7 for Sunday. Tests verify Sunday and Monday matching, preserve weekday 0 behavior, and validate the next Sunday occurrence through Next.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: treating cron weekday 7 as Sunday.
Description check ✅ Passed The description directly explains the weekday 7 Sunday fix and the added regression test.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant