#2647·BrowserOS

Scheduled job API accepts invalid cadence fields that can break alarm creation

Author: avinashgolaCreated Sep 9, 2026Updated Sep 9, 2026

Summary

The scheduled-job server route accepts invalid scheduleTime and scheduleInterval values even though the extension alarm code assumes those fields are already valid. UI-created jobs are protected by the React form schema, but imports and direct API writes can persist schedules that later fail to create a usable chrome.alarms entry.

Evidence

packages/browseros-agent/apps/server/src/api/routes/scheduled-jobs.ts currently validates the cadence fields as loose nullable primitives:

typescript
scheduleType: z.enum(['daily', 'hourly', 'minutes']),
scheduleTime: z.string().nullish(),
scheduleInterval: z.number().nullish(),

There is no cross-field validation requiring:

  • daily jobs to have an HH:MM scheduleTime
  • hourly / minutes jobs to have a positive integer interval
  • interval values to stay within the same bounds the UI enforces

The alarm builder then assumes valid data in packages/browseros-agent/apps/app/lib/schedules/createAlarmFromJob.ts:

typescript
const [hours, minutes] = timeString.split(':').map(Number)
...
scheduled.setHours(hours, minutes, 0, 0)

For interval schedules it passes the persisted number directly to Chrome alarms:

typescript
delayInMinutes: job.scheduleInterval,
periodInMinutes: job.scheduleInterval,

NewScheduledTaskDialog.tsx has stricter validation (scheduleInterval is an int from 1 to 60, and daily requires time), but the server route is also used by imports and programmatic callers, so invalid data can bypass the UI.

Repro sketch

Send any of these payloads to PUT /scheduled-jobs/:jobId or include them in /scheduled-jobs/import:

json
{ "name": "bad daily", "query": "run", "scheduleType": "daily", "scheduleTime": "not-a-time" }
json
{ "name": "bad interval", "query": "run", "scheduleType": "minutes", "scheduleInterval": 0 }

The route accepts the row, but the extension later tries to create an alarm from invalid/zero cadence data.

Expected

The server should enforce the same schedule invariants as the UI, preferably with cross-field Zod validation on the route schemas used for normal writes and imports.

Actual

Invalid schedule cadence fields are accepted and persisted, leaving alarm creation and catch-up logic to handle impossible schedules downstream.