{"record":{"id":"1ff221b17edc828e","repo":"coreybutler/nvm-windows","slug":"scheduling-error-invalid-interval-q","errorCode":null,"errorMessage":"scheduling error: invalid interval %q","messagePattern":"scheduling error: invalid interval %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/upgrade/register.go","lineNumber":134,"sourceCode":"\t\tfallthrough\n\tcase \"DAILY\":\n\t\tfallthrough\n\tcase \"WEEKLY\":\n\t\tfallthrough\n\tcase \"MONTHLY\":\n\t\tfallthrough\n\tcase \"ONCE\":\n\t\tfallthrough\n\tcase \"ONSTART\":\n\t\tfallthrough\n\tcase \"ONLOGON\":\n\t\tfallthrough\n\tcase \"ONIDLE\":\n\t\tfallthrough\n\tcase \"EVENT\":\n\t\tinterval = strings.ToUpper(interval)\n\tdefault:\n\t\treturn fmt.Errorf(\"scheduling error: invalid interval %q\", interval)\n\t}\n\n\tstart := \"00:00\"\n\tif len(startTime) > 0 {\n\t\tstart = startTime[0]\n\t}\n\n\ttmp, err := os.MkdirTemp(\"\", \"nvm4w-regitration-*\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"scheduling error: %v\", err)\n\t}\n\tdefer os.RemoveAll(tmp)\n\n\tscript := fmt.Sprintf(`\n@echo off\nset errorlog=\"error.log\"\nset output=\"%s\\output.log\"\nschtasks /create /tn \"%s\" /tr \"cmd.exe /c %s\" /sc %s /st %s /F > %%output%% 2>&1","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/coreybutler/nvm-windows/blob/5b18223ca19ff50d707f35410dbc6bd440a9f74d/src/upgrade/register.go#L116-L152","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nerr := ScheduleTask(\"nvm4w-update\", cmd, \"minutely\")\n\n// after\nerr := ScheduleTask(\"nvm4w-update\", cmd, \"MINUTE\")","handlingStrategy":"validation","validationCode":"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}\niv := strings.ToUpper(strings.TrimSpace(interval))\nif !validIntervals[iv] {\n    return fmt.Errorf(\"unsupported interval %q; use one of MINUTE|HOURLY|DAILY|WEEKLY|MONTHLY|ONCE|ONSTART|ONLOGON|ONIDLE|EVENT\", interval)\n}","typeGuard":"func isValidInterval(s string) bool {\n    switch strings.ToUpper(strings.TrimSpace(s)) {\n    case \"MINUTE\",\"HOURLY\",\"DAILY\",\"WEEKLY\",\"MONTHLY\",\"ONCE\",\"ONSTART\",\"ONLOGON\",\"ONIDLE\",\"EVENT\":\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["nvm-windows","scheduled-tasks","schtasks","validation","windows"],"backgroundTag":null,"analyzedSha":"5b18223ca19ff50d707f35410dbc6bd440a9f74d","analyzedAt":"2026-08-15T10:06:51.428Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}