Skip to content

fix(schedule): reject a blank --cron on update, matching create - #371

Open
x15967311210-crypto wants to merge 1 commit into
TestSprite:mainfrom
x15967311210-crypto:fix/schedule-update-empty-cron
Open

x15967311210-crypto wants to merge 1 commit into
TestSprite:mainfrom
x15967311210-crypto:fix/schedule-update-empty-cron

Conversation

@x15967311210-crypto

@x15967311210-crypto x15967311210-crypto commented Oct 11, 2026 •

Copy link
Copy Markdown

Season 4 CLI Improvement Bonus

  • I'm entering this PR for the Season 4 CLI Improvement Bonus

Discord username: @rr_1999

What does this PR do?

schedule create rejects a blank --cron up front, but schedule update never applied that guard:

$ testsprite schedule update sch_1 --cron ""
This schedule will run on the cron ``. Each run is a full test run. Check your balance with `testsprite usage`.
# exit 0 — the empty cadence is PATCHed to the server

The cause is exactly what #363 describes: runCreate validates opts.cron before building the request body, while runUpdate spread opts.cron into the PATCH body unchecked.

This applies the same contract to update — a supplied --cron is trimmed and must not be blank — and the trimmed value is what goes into both the request body and the frequency advisory, matching create.

Related issue

Closes #363

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that changes existing behavior)
  • Documentation only
  • Build / CI / chore

Checklist

  • PR targets the main branch.
  • Commits follow Conventional Commits (fix(schedule): ...).
  • npm run lint and npm run format:check pass.
  • npm run typecheck passes.
  • npm test passes and coverage stays at or above the 80% gate. (115 files, 4580 passed / 11 skipped, 0 failed)
  • New behavior is covered by unit tests (mock-based; no network or credentials required).
  • No secrets, API keys, internal endpoints, or personal data are included.
  • User-facing changes are reflected in README.md / DOCUMENTATION.md where relevant (no docs surface changes; message-only rejection path).

Notes for reviewers

Wording choice. Create's guard reads --cron is required and must not be empty, which is accurate there because cron is mandatory on create. On update --cron is optional, so this uses the repo's established phrasing for an optional flag supplied blank — must not be empty or whitespace-only (same as --password / --username in project.ts and project-env.ts) — through the same schedule-local localValidationError helper create uses.

Tests. Two on the update side (blank rejects locally before any request; a whitespace-padded value is trimmed before the PATCH) plus a create-side whitespace-only case, so the two verbs are pinned to the same contract. Verified non-vacuous: the two update tests fail against the previous schedule.ts.

Discord username: @rr_1999

Summary by CodeRabbit

  • Bug Fixes
    • Blank or whitespace-only cron expressions are now rejected before a schedule update is sent.
    • Leading and trailing whitespace is removed from cron expressions before saving.

`schedule create` rejected an empty --cron up front, but `schedule update
--cron ""` slipped past that guard and PATCHed an empty cadence to the
server. Apply the same trim-and-reject-blank contract to update, so the two
verbs agree on what a valid --cron is.

Refs TestSprite#363
@github-actions

Copy link
Copy Markdown

Thanks for the PR, @x15967311210-crypto! It links an issue, but that issue isn't assigned to you yet: #363 (unassigned). Per our workflow, claim the issue first by commenting /assign on it (the triage bot assigns you automatically). If it's already assigned to someone else, please coordinate with them or pick another issue — unclaimed-issue PRs are not reviewed. After fixing it, edit the PR description or push a commit to re-run this check. See CONTRIBUTING → Contribution model.

@github-actions github-actions Bot added the needs-issue PR not linked to an issue yet — please open one first and claim it (see CONTRIBUTING) label Oct 11, 2026
@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: TestSprite/testsprite-cli/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 30a6a76f-5f1c-42eb-9e2a-2ea2842d3d87

📥 Commits

Reviewing files that changed from the base of the PR and between 988c035 and 9d15db3.


📒 Files selected for processing (3)
  • src/commands/schedule.create.test.ts
  • src/commands/schedule.ts
  • src/commands/schedule.write.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.



Walkthrough

Schedule updates now reject empty or whitespace-only cron values locally. The command trims valid cron values before sending them in the PATCH body and before displaying the frequency advisory. Tests cover update validation and create-side whitespace validation.

Changes

Schedule cron validation

Layer / File(s) Summary
Update cron validation and normalization
src/commands/schedule.ts, src/commands/schedule.write.test.ts, src/commands/schedule.create.test.ts
runUpdate rejects empty or whitespace-only cron values locally. It sends the trimmed value in the PATCH body and uses it in the frequency advisory. Tests cover update validation, trimming, and create-side whitespace validation.

Priority: ⬇️ Low

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

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 9d15d

Blank cron values are rejected locally, and valid values are normalized before use. No material merge risk was identified.

Pre-merge checks | Passed 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 and concisely describes the main change: rejecting blank --cron values during schedule update to match schedule create validation.
Linked Issues check Passed Issue #363 requires local rejection of an empty --cron for schedule update, before the PATCH request. runUpdate trims a supplied value, rejects an empty result with VALIDATION_ERROR, and uses …
Out of Scope Changes check Passed The changed files are limited to schedule update validation, schedule advisory/request handling, and focused unit tests. These changes directly implement issue #363. No unrelated production behavior o…
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 3 files.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

needs-issue PR not linked to an issue yet — please open one first and claim it (see CONTRIBUTING)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Hackathon] fix(schedule): update --cron "" bypasses the empty-cron guard enforced by create

1 participant