fix(schedules): migrate to trigger dev #1618
Merged
icecrasher321 merged 4 commits intostagingfrom Oct 13, 2025
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
There was a problem hiding this comment.
Greptile Overview
Summary
Added authentication to the schedule execution endpoint to match the security pattern used by other cron routes.
- route.ts:67-74: Added
verifyCronAuthcall to validate the cron authentication token before processing any schedules - route.test.ts:14-26: Created
createMockRequest()helper to generate mock NextRequest with proper authorization headers for testing - route.test.ts:34-37: Mocked
verifyCronAuthto return null (success) for all test cases - cronjobs.yaml:44-46: Added
CRON_SECRETenvironment variable to cron job containers - cronjobs.yaml:64: Added Authorization header to curl requests using the
CRON_SECRETvalue
This change ensures that only authenticated Kubernetes cron jobs can trigger schedule executions, preventing unauthorized access to the endpoint.
Confidence Score: 5/5
- This PR is safe to merge with minimal risk
- The changes follow the established authentication pattern used by other cron routes in the codebase (logs/cleanup, webhooks/poll/gmail, webhooks/poll/outlook), with proper implementation in both the route handler and tests. The Helm template correctly passes the CRON_SECRET environment variable and includes it in the Authorization header.
- No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/app/api/schedules/execute/route.ts | 5/5 | Added cron authentication to schedule execution endpoint using verifyCronAuth, matching the security pattern used by other cron routes |
| apps/sim/app/api/schedules/execute/route.test.ts | 5/5 | Updated tests to pass NextRequest with proper authorization headers and mocked verifyCronAuth to return null (success) |
| helm/sim/templates/cronjobs.yaml | 5/5 | Added CRON_SECRET environment variable and Authorization header to cron job curl requests for authentication |
Sequence Diagram
sequenceDiagram
participant CronJob as Kubernetes CronJob
participant API as Schedule Execute Route
participant Auth as Cron Auth Middleware
participant DB as Database
participant Executor as Workflow Executor
CronJob->>API: GET /api/schedules/execute
API->>Auth: Verify cron authentication
alt Authentication fails
Auth-->>API: Return error response
API-->>CronJob: 401 Unauthorized
else Authentication succeeds
Auth-->>API: Continue
API->>DB: Query due schedules
DB-->>API: Return schedules
loop For each schedule
API->>DB: Load workflow
DB-->>API: Workflow data
API->>Executor: Execute workflow
Executor-->>API: Result
API->>DB: Update schedule
end
API-->>CronJob: 200 OK
end
3 files reviewed, no comments
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.
Summary
Move schedules to trigger.dev and cleanup code. Add verifyCronAuth check to schedules execution route.
Type of Change
Testing
Tested manually in staging env.
Checklist