{"record":{"id":"5f3db5f7e8066695","repo":"hashicorp/nomad","slug":"end-cannot-be-sooner-than-start-end-q-start-q","errorCode":null,"errorMessage":"end cannot be sooner than start; end=%q, start=%q","messagePattern":"end cannot be sooner than start; end=%q, start=%q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/task_sched.go","lineNumber":155,"sourceCode":"\t// get end time for prev to see if we're within the run schedule,\n\t// and from next to get the next pause time.\n\tend, err := cronexpr.Parse(t.End + \" * * * *\") // TODO: if we want to exclude seconds, prefix \"* \" + t.End here\n\tif err != nil {\n\t\treturn 0, 0, fmt.Errorf(\"invalid end time in schedule: %q; %w\", t.End, err)\n\t}\n\n\tstartNext := start.Next(from)\n\t// we'll check the previous start to see if we are currently between it\n\t// and the previous run's end, i.e. it should be running right now!\n\tstartPrev := start.Next(from.Add(-24 * time.Hour))\n\n\t// generate ends from starts, so they always come after\n\tendNext := end.Next(startNext)\n\tendPrev := end.Next(startPrev)\n\n\t// next end must be on the same day as next start\n\tif endNext.Day() > startNext.Day() {\n\t\treturn 0, 0, fmt.Errorf(\"end cannot be sooner than start; end=%q, start=%q\", endNext, startNext)\n\t}\n\n\t// we're in the midst of it right now!\n\tif startPrev.Before(from) && endPrev.After(from) {\n\t\treturn 0, endPrev.Sub(from), nil\n\t}\n\n\treturn startNext.Sub(from), endNext.Sub(from), nil\n}\n","sourceCodeStart":137,"sourceCodeEnd":165,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/task_sched.go#L137-L165","documentation":"Returned by TaskScheduleCron.Next when the parsed end time lands before the corresponding start time, producing an inverted run window. The schedule would never be active, which is treated as a configuration error.","triggerScenarios":"Thrown at nomad/structs/task_sched.go:155 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Swap or adjust start/end so end is chronologically after start","Use 24-hour-aware values, e.g. start \"0 0 9 * *\" and end \"17 *\" for 9am-5pm"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}