Cherrypick scheduler panics - #162
Merged
Merged
Conversation
* fix scheduler panic if user puts in wrong schedule Signed-off-by: Cassandra Coyle <cassie@diagrid.io> * add test Signed-off-by: Cassandra Coyle <cassie@diagrid.io> --------- Signed-off-by: Cassandra Coyle <cassie@diagrid.io>
JoshVanL
approved these changes
Jul 27, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR cherry-picks fixes to make cron schedule parsing more robust by preventing panics on malformed timezone-prefixed specs and by rejecting unsupported combinations of timezone prefixes with @every interval schedules.
Changes:
- Avoid panics when parsing timezone-prefixed specs by using whitespace-aware splitting and explicit validation.
- Reject
TZ=/CRON_TZ=prefixes when used with@every <duration>schedules, returning a clear parse-time error. - Expand test coverage for timezone parsing, including whitespace handling and DST behavior, and update documentation accordingly.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
cron/parser.go |
Hardens timezone prefix parsing and rejects timezone + @every specs. |
cron/parser_test.go |
Adds error cases, whitespace coverage, @every rejection checks, and DST behavior validation. |
cron/doc.go |
Documents that timezone prefixes are not supported for @every <duration> schedules. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
133
to
+140
| spec = strings.TrimSpace(spec[i:]) | ||
|
|
||
| // An @every schedule fires at a fixed interval and has no wall clock for | ||
| // a timezone to apply to, so reject the pair rather than silently | ||
| // dropping the location. | ||
| if strings.HasPrefix(spec, "@every ") { | ||
| return nil, fmt.Errorf("timezone is not supported for @every schedules: %s", prefixed) | ||
| } |
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.
cherrypick both:
#161
#160