Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/validate-cron-input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"agents": patch
---

Validate cron expressions when scheduling tasks
5 changes: 5 additions & 0 deletions packages/agents/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,11 @@ export class Agent<
return schedule;
}
if (typeof when === "string") {
try {
parseCronExpression(when);
} catch {
throw new Error(`Invalid cron expression: ${when}`);
}
const nextExecutionTime = getNextCronTime(when);
const timestamp = Math.floor(nextExecutionTime.getTime() / 1000);

Expand Down
Loading