Skip to content

fix(cron): stop describing a month-restricted schedule as daily - #319

Open
naufalfx805-source wants to merge 1 commit into
TestSprite:mainfrom
naufalfx805-source:fix/cron-describe-ignores-month
Open

fix(cron): stop describing a month-restricted schedule as daily#319
naufalfx805-source wants to merge 1 commit into
TestSprite:mainfrom
naufalfx805-source:fix/cron-describe-ignores-month

Conversation

@naufalfx805-source

@naufalfx805-source naufalfx805-source commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Closes #318

describeCron destructured the five cron fields but skipped the month, so a schedule restricted to certain months was described by its finer fields alone. 0 3 * 6 * — daily at 03:00, but only in June — came back as daily at 03:00.

That string is printed by formatScheduleFrequencyAdvisory beside a frequency runsPerMonth computes correctly, so schedule create (src/commands/schedule.ts:245) and schedule update (:347) rendered a sentence that contradicts itself:

This schedule will run ~3 time(s)/month (daily at 03:00).

Fix. None of the phrasings describeCron produces can carry "only in these months", so a restricted month now falls back to the raw expression — the same thing the function already does for every other shape it cannot state exactly, and what its own docstring asks for: "a wrong description is worse than the raw expression". runsPerMonth is untouched; it already handled the month correctly.

Tests. Two added, both verified failing on main and passing with the change:

  • describeCron > returns the raw expression when the month is restricted — covers 0 3 * 6 *, 0 3 * 1,7 *, 0 3 * */6 *, 0 3 1 3 *, 0 3 * 6 1. Without the fix: expected 'daily at 03:00' to be '0 3 * 6 *'.
  • formatScheduleFrequencyAdvisory > does not call a month-restricted schedule daily — asserts the advisory keeps ~3 time(s)/month and stops saying daily.

npx vitest run src/lib/cron.test.ts → 24 passed. src/commands/schedule → 66 passed.

The gap in the existing suite was that describeCron was never exercised with a non-wildcard month, and the one advisory test that uses one (0 3 1 1 *) asserts only the frequency half, not the description.

Summary by CodeRabbit

  • Bug Fixes
    • Improved cron schedule descriptions for expressions restricted to specific months.
    • These schedules now display the original cron expression instead of an inaccurate daily, weekly, or monthly description.
    • Preserved reduced monthly frequency information in schedule guidance.

describeCron destructured the 5 cron fields but skipped the month, so a
schedule restricted to certain months was described by its finer fields
alone. `0 3 * 6 *` -- daily at 03:00, but only in June -- came back as
"daily at 03:00".

That description is printed by formatScheduleFrequencyAdvisory beside a
frequency that runsPerMonth computes correctly, so `schedule create` and
`schedule update` rendered a sentence contradicting itself:

    This schedule will run ~3 time(s)/month (daily at 03:00).

None of the phrasings describeCron produces can carry "only in these
months", so a restricted month now falls back to the raw expression --
the same thing the function already does for every other shape it cannot
state exactly, and what its own docstring asks for: "a wrong description
is worse than the raw expression".
@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 84100b57-57f8-4680-9db7-a4ac76e56536

📥 Commits

Reviewing files that changed from the base of the PR and between 40d18d2 and a0ffaeb.

📒 Files selected for processing (2)
  • src/lib/cron.test.ts
  • src/lib/cron.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


Walkthrough

describeCron now returns raw expressions for month-restricted schedules. Regression tests verify direct descriptions and schedule advisories preserve the monthly frequency and omit incorrect “daily” wording.

Changes

Cron description fix

Layer / File(s) Summary
Handle restricted months in cron descriptions
src/lib/cron.ts, src/lib/cron.test.ts
describeCron detects non-wildcard month fields and returns the original expression. Tests verify raw output, correct monthly frequency, and the absence of “daily” wording.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to a0ffa

Month-restricted schedules now retain their raw cron expression instead of being described as daily, preventing contradictory schedule advisories. The change is localized and tested, with no actionable merge-blocking risk remaining beyond normal checks and review.

Suggested reviewers: ruili-testsprite

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the fix for incorrect daily descriptions of month-restricted cron schedules.
Linked Issues check ✅ Passed The change addresses issue #318 by returning raw expressions for restricted months and adding regression coverage for advisory consistency.
Out of Scope Changes check ✅ Passed The changes are limited to the cron description fix and its regression and advisory tests.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

bug: schedule advisory calls a month-restricted cron "daily", contradicting the frequency beside it

1 participant