coreybutler/nvm-windows · error
scheduling error: invalid interval %q
Error message
scheduling error: invalid interval %q
What it means
Validation error from ScheduleTask(): the interval argument is not one of the schtasks-supported schedule types (MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, ONCE, ONSTART, ONLOGON, ONIDLE, EVENT, case-insensitive). It is checked before any temp file or task is created, so nothing is mutated when it fires.
Source
Thrown at src/upgrade/register.go:134
fallthrough
case "DAILY":
fallthrough
case "WEEKLY":
fallthrough
case "MONTHLY":
fallthrough
case "ONCE":
fallthrough
case "ONSTART":
fallthrough
case "ONLOGON":
fallthrough
case "ONIDLE":
fallthrough
case "EVENT":
interval = strings.ToUpper(interval)
default:
return fmt.Errorf("scheduling error: invalid interval %q", interval)
}
start := "00:00"
if len(startTime) > 0 {
start = startTime[0]
}
tmp, err := os.MkdirTemp("", "nvm4w-regitration-*")
if err != nil {
return fmt.Errorf("scheduling error: %v", err)
}
defer os.RemoveAll(tmp)
script := fmt.Sprintf(`
@echo off
set errorlog="error.log"
set output="%s\output.log"
schtasks /create /tn "%s" /tr "cmd.exe /c %s" /sc %s /st %s /F > %%output%% 2>&1View on GitHub (pinned to 5b18223ca1)
Solutions
- Use one of the documented keywords: MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, ONCE, ONSTART, ONLOGON, ONIDLE, or EVENT
- Trim and uppercase the interval before calling: strings.ToUpper(strings.TrimSpace(interval))
- For intervals like 'every 5 minutes', use MINUTE and rely on the schtasks /MO modifier semantics documented in the function comment
Example fix
// before
err := ScheduleTask("nvm4w-update", cmd, "minutely")
// after
err := ScheduleTask("nvm4w-update", cmd, "MINUTE") Defensive patterns
Strategy: validation
Validate before calling
var validIntervals = map[string]bool{"MINUTE":true,"HOURLY":true,"DAILY":true,"WEEKLY":true,"MONTHLY":true,"ONCE":true,"ONSTART":true,"ONLOGON":true,"ONIDLE":true,"EVENT":true}
iv := strings.ToUpper(strings.TrimSpace(interval))
if !validIntervals[iv] {
return fmt.Errorf("unsupported interval %q; use one of MINUTE|HOURLY|DAILY|WEEKLY|MONTHLY|ONCE|ONSTART|ONLOGON|ONIDLE|EVENT", interval)
} Type guard
func isValidInterval(s string) bool {
switch strings.ToUpper(strings.TrimSpace(s)) {
case "MINUTE","HOURLY","DAILY","WEEKLY","MONTHLY","ONCE","ONSTART","ONLOGON","ONIDLE","EVENT":
return true
}
return false
} Prevention
- Define interval choices as typed constants instead of free strings
- Trim/normalize input before validation
- Remember these map 1:1 to schtasks /sc values, not cron syntax
When it happens
Trigger: Calling upgrade.ScheduleTask(name, cmd, "minutely") or "secondly", "yearly", "" (empty string), or any string not in the accepted switch list; the comparison is strings.ToUpper(interval) against the fixed set.
Common situations: Passing a cron-style expression or natural-language interval ('every 5 minutes') instead of an schtasks keyword; typo or trailing whitespace in the interval constant; passing an empty string when the caller forgot to default it.
Related errors
- scheduling error: %v %s
- unscheduling error: %v %s
- NVM_SYMLINK is set to a physical file/directory at %s Please
- failed to elevate permissions to create symlink
- Invalid character(s) found in patch number %q
AI-assisted analysis of coreybutler/nvm-windows@5b18223ca1 (2026-08-15).
Data as JSON: /api/errors/1ff221b17edc828e.
Report an issue: GitHub.