fix(schedules): restore enabling/disabling of schedules, fix premature cron validation#1807
Merged
waleedlatif1 merged 1 commit intostagingfrom Nov 4, 2025
Merged
fix(schedules): restore enabling/disabling of schedules, fix premature cron validation#1807waleedlatif1 merged 1 commit intostagingfrom
waleedlatif1 merged 1 commit intostagingfrom
Conversation
…e cron validation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
There was a problem hiding this comment.
Greptile Overview
Greptile Summary
This PR fixes two critical bugs in the schedules system: restores the ability to enable/disable schedules for workspace members, and fixes premature cron validation that was incorrectly validating fields for all schedule frequencies.
Key Changes:
- Authorization Fix: Added workspace permission checking in the PUT endpoint (
apps/sim/app/api/schedules/[id]/route.ts:120-138) to allow workspace members withwriteoradminpermissions to enable/disable schedules, not just the workflow owner - Cron Validation Fix: Removed premature cron validation from
getScheduleTimeValues()(apps/sim/lib/schedules/utils.ts:145-153) that was validating thecronExpressionfield regardless of the selected schedule type (daily, weekly, etc.) - Value Sanitization: Added logic to null out
cronExpressionfor non-custom schedule types (apps/sim/app/api/schedules/route.ts:304-307) before generating the cron expression, ensuring only the relevant fields are used - Cache Control: Updated Cache-Control header from
max-age=30tono-store, max-age=0(apps/sim/app/api/schedules/route.ts:124) to prevent stale schedule data from being cached
The authorization fix properly handles workspace-shared workflows, and the cron validation fix ensures users can select schedule frequencies without encountering validation errors for fields they haven't configured.
Confidence Score: 5/5
- This PR is safe to merge with minimal risk
- All changes are well-targeted bug fixes that address specific issues. The authorization logic correctly checks workspace permissions using the existing
getUserEntityPermissionsutility, the cron validation removal eliminates premature validation while keeping proper validation at the right point (after cron generation), and the sanitization ensures clean separation between schedule types - No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/lib/schedules/utils.ts | 5/5 | Removed premature cron validation from getScheduleTimeValues that was incorrectly validating all fields regardless of schedule type selection |
| apps/sim/app/api/schedules/route.ts | 5/5 | Added schedule value sanitization to null out cronExpression for non-custom schedule types, and changed Cache-Control from max-age=30 to no-store, max-age=0 |
| apps/sim/app/api/schedules/[id]/route.ts | 5/5 | Enhanced authorization logic by adding workspaceId to query and checking workspace permissions for users who aren't the workflow owner |
Sequence Diagram
sequenceDiagram
participant User
participant API as PUT /api/schedules/[id]
participant DB as Database
participant Auth as getUserEntityPermissions
User->>API: Request to enable/disable schedule
API->>DB: Query schedule by ID
DB-->>API: Schedule record
API->>DB: Query workflow (userId, workspaceId)
DB-->>API: Workflow record
alt User is workflow owner
API->>API: isAuthorized = true
else User is not owner AND workflow has workspaceId
API->>Auth: Check workspace permissions
Auth-->>API: Permission level (write/admin/read/null)
API->>API: isAuthorized = (permission === 'write' || 'admin')
end
alt Not authorized
API-->>User: 403 Forbidden
else Authorized
API->>DB: Update schedule status
DB-->>API: Success
API-->>User: 200 OK with updated schedule
end
3 files reviewed, no comments
waleedlatif1
added a commit
that referenced
this pull request
Nov 12, 2025
…e cron validation (#1807)
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
Type of Change
Testing
Tested manually
Checklist