{"record":{"id":"82234d38af902fca","repo":"temporalio/temporal","slug":"executabletasktracker-encountered-unknown-task-sta","errorCode":null,"errorMessage":"ExecutableTaskTracker encountered unknown task state: %v","messagePattern":"ExecutableTaskTracker encountered unknown task state: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/history/replication/executable_task_tracker.go","lineNumber":151,"sourceCode":"\t\t\t\t)\n\t\t\t\t// unable to save poison pill, retry later\n\t\t\t\telement = element.Next()\n\t\t\t\tcontinue Loop\n\t\t\t}\n\t\t\tnextElement := element.Next()\n\t\t\tt.taskQueue.Remove(element)\n\t\t\telement = nextElement\n\t\tcase ctasks.TaskStateAborted:\n\t\t\t// noop, do not remove from queue, let it block low watermark\n\t\t\telement = element.Next()\n\t\tcase ctasks.TaskStateCancelled:\n\t\t\t// noop, do not remove from queue, let it block low watermark\n\t\t\telement = element.Next()\n\t\tcase ctasks.TaskStatePending:\n\t\t\t// noop, do not remove from queue, let it block low watermark\n\t\t\telement = element.Next()\n\t\tdefault:\n\t\t\tpanic(fmt.Sprintf(\n\t\t\t\t\"ExecutableTaskTracker encountered unknown task state: %v\",\n\t\t\t\ttaskState,\n\t\t\t))\n\t\t}\n\t}\n\n\tif element := t.taskQueue.Front(); element != nil {\n\t\tinclusiveLowWatermarkInfo := WatermarkInfo{\n\t\t\tWatermark: element.Value.(TrackableExecutableTask).TaskID(),\n\t\t\tTimestamp: element.Value.(TrackableExecutableTask).TaskCreationTime(),\n\t\t}\n\t\treturn &inclusiveLowWatermarkInfo\n\t} else if t.exclusiveHighWatermarkInfo != nil {\n\t\tinclusiveLowWatermarkInfo := *t.exclusiveHighWatermarkInfo\n\t\treturn &inclusiveLowWatermarkInfo\n\t} else {\n\t\treturn nil\n\t}","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/service/history/replication/executable_task_tracker.go#L133-L169","documentation":"LowWatermark scans the tracker's task queue to compute the ackable low watermark, switching on each task's state (Acked, Nacked, Aborted, Cancelled, Pending). A state outside this set means a TrackableExecutableTask returned an unexpected State() value, so the function panics rather than computing a wrong watermark. It is an exhaustiveness guard on the task-state enum.","triggerScenarios":"A new ctasks.TaskState constant added without updating LowWatermark's switch; a custom/buggy TrackableExecutableTask implementation returning an undefined state; memory corruption of the state field.","commonSituations":"Forking or upgrading temporal-server where a task state enum was extended on one side only; custom task implementations in internal forks.","solutions":["Add the missing task state case to LowWatermark's switch, deciding whether it should block the low watermark (like Pending) or be removable (like Acked)","Grep ctasks.TaskState* constants and verify every one is handled in the switch","Check any custom TrackableExecutableTask implementations return only defined states","Run with -race if hit on an unmodified build to rule out a state race"],"exampleFix":"// before\ncase ctasks.TaskStatePending:\n  element = element.Next()\ndefault:\n  panic(fmt.Sprintf(\"ExecutableTaskTracker encountered unknown task state: %v\", taskState))\n// after\ncase ctasks.TaskStatePending, ctasks.TaskStateNewlyAdded: // handle newly added state\n  element = element.Next()\ndefault:\n  panic(fmt.Sprintf(\"ExecutableTaskTracker encountered unknown task state: %v\", taskState))","handlingStrategy":"type-guard","validationCode":"// Validate states are known before tasks enter the tracker:\nif !isKnownTaskState(task.State()) {\n  return fmt.Errorf(\"task %v has undefined state %v\", task.TaskID(), task.State())\n}","typeGuard":"func isKnownTaskState(s ctasks.TaskState) bool {\n  switch s {\n  case ctasks.TaskStateAcked, ctasks.TaskStateNacked, ctasks.TaskStateAborted,\n    ctasks.TaskStateCancelled, ctasks.TaskStatePending:\n    return true\n  }\n  return false\n}","tryCatchPattern":"func safeLowWatermark(t *replication.ExecutableTaskTracker) (wm *replication.WatermarkInfo, err error) {\n  defer func() { if r := recover(); r != nil { err = fmt.Errorf(\"task state panic: %v\", r) } }()\n  return t.LowWatermark(), nil\n}","preventionTips":["Handle every ctasks.TaskState constant in LowWatermark's switch","Update the switch in the same change that adds a new task state","Ensure custom TrackableExecutableTask implementations return only defined states"],"tags":["go","replication","task-state","unhandled-enum-case"],"backgroundTag":"unknown-task-state","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}