{"record":{"id":"e931704bdddcee30","repo":"temporalio/temporal","slug":"interval-is-nil","errorCode":null,"errorMessage":"interval is nil","messagePattern":"interval is nil","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/worker/scheduler/spec.go","lineNumber":257,"sourceCode":"\tcheckRanges(scs.Hour, \"Hour\", 0, 23)\n\tcheckRanges(scs.DayOfMonth, \"DayOfMonth\", 1, 31)\n\tcheckRanges(scs.Month, \"Month\", 1, 12)\n\tcheckRanges(scs.Year, \"Year\", minCalendarYear, maxCalendarYear)\n\tcheckRanges(scs.DayOfWeek, \"DayOfWeek\", 0, 6)\n\n\tif len(scs.Comment) > maxCommentLen {\n\t\terrs = append(errs, \"comment is too long\")\n\t}\n\n\tif len(errs) > 0 {\n\t\treturn errors.New(\"invalid calendar spec: \" + strings.Join(errs, \", \"))\n\t}\n\treturn nil\n}\n\nfunc validateInterval(i *schedulepb.IntervalSpec) error {\n\tif i == nil {\n\t\treturn errors.New(\"interval is nil\")\n\t}\n\t// TODO: use timestamp.ValidateAndCapProtoDuration after switching to state machine based implementation.\n\t// \tNot adding it to workflow based implementation to avoid potential non-determinism errors.\n\tiv, phase := timestamp.DurationValue(i.Interval), timestamp.DurationValue(i.Phase)\n\tif iv < time.Second {\n\t\treturn errors.New(\"interval is too small\")\n\t} else if phase < 0 {\n\t\treturn errors.New(\"phase is negative\")\n\t} else if phase >= iv {\n\t\treturn errors.New(\"phase cannot be greater than Interval\")\n\t}\n\treturn nil\n}\n\nfunc (b *SpecBuilder) loadTimezone(spec *schedulepb.ScheduleSpec) (*time.Location, error) {\n\tif spec.TimezoneData != nil {\n\t\treturn time.LoadLocationFromTZData(spec.TimezoneName, spec.TimezoneData)\n\t}","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/service/worker/scheduler/spec.go#L239-L275","documentation":"validateInterval rejects an IntervalSpec that is nil. A nil interval means the interval portion of the schedule spec was never populated, so the scheduler cannot compute occurrences; canonicalizeSpec calls this during spec compilation and fails fast with this error.","triggerScenarios":"Submitting a ScheduleSpec whose Interval list contains a nil *schedulepb.IntervalSpec — typically when building the protobuf message with an unpopulated pointer, or an update request that clears the interval field.","commonSituations":"Constructing schedulepb.ScheduleSpec in Go where an interval variable was declared but not assigned; JSON/YAML deserialization omitting the interval object; partial updates that nil out Interval accidentally.","solutions":["Ensure the IntervalSpec is fully constructed (both Interval and Phase durations) before including it in the spec.","Check for nil before appending to spec.Interval and return a clearer config error to the user.","If an interval schedule was intended, set e.g. i.Interval = durationpb.New(24*time.Hour).","If a calendar or cron-based spec was intended, remove the empty interval entry entirely instead of sending a nil."],"exampleFix":"// before\nvar iv *schedulepb.IntervalSpec // left nil\nspec.Interval = []*schedulepb.IntervalSpec{iv}\n// after\niv := &schedulepb.IntervalSpec{Interval: durationpb.New(24 * time.Hour)}\nspec.Interval = []*schedulepb.IntervalSpec{iv}","handlingStrategy":"validation","validationCode":"if iv == nil {\n    return errors.New(\"interval spec must be set before creating schedule\")\n}\nif iv.Interval == nil || iv.Interval.AsDuration() <= 0 {\n    return errors.New(\"interval duration must be positive\")\n}","typeGuard":"func hasInterval(spec *schedulepb.ScheduleSpec) bool {\n    return len(spec.GetInterval()) > 0 && spec.GetInterval()[0] != nil && spec.GetInterval()[0].GetInterval() != nil\n}","tryCatchPattern":null,"preventionTips":["Never append unassigned interval pointers to spec.Interval","Check deserialized specs for nil sub-messages before UpdateSchedule","Remove empty interval entries if a calendar/cron spec was intended instead","Initialize IntervalSpec with both Interval and Phase fields explicitly"],"tags":["go","scheduler","validation","interval-spec"],"backgroundTag":"nil-spec-field","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}