{"record":{"id":"55f9a8c82f2f1e42","repo":"kubernetes/kops","slug":"task-is-nil","errorCode":null,"errorMessage":"task is nil","messagePattern":"task is nil","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/template_functions.go","lineNumber":578,"sourceCode":"\tvar keys []string\n\tfor key := range tasks {\n\t\tif strings.HasPrefix(key, prefix) {\n\t\t\tkeys = append(keys, key)\n\t\t}\n\t}\n\tsort.Strings(keys)\n\n\tmatches := make([]fi.CloudupTask, 0, len(keys))\n\tfor _, key := range keys {\n\t\tmatches = append(matches, tasks[key])\n\t}\n\treturn matches, nil\n}\n\n// TaskKey returns the canonical task key used in the task map.\nfunc (tf *TemplateFunctions) TaskKey(task fi.CloudupTask) (string, error) {\n\tif task == nil {\n\t\treturn \"\", fmt.Errorf(\"task is nil\")\n\t}\n\thasName, ok := task.(fi.HasName)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"task %T does not implement HasName\", task)\n\t}\n\tname := fi.ValueOf(hasName.GetName())\n\tif name == \"\" {\n\t\treturn \"\", fmt.Errorf(\"task %T did not have a name\", task)\n\t}\n\treturn fi.TypeNameForTask(task) + \"/\" + name, nil\n}\n\n// SharedVPC is a simple helper function which makes the templates for a shared VPC clearer\nfunc (tf *TemplateFunctions) SharedVPC() bool {\n\treturn tf.Cluster.SharedVPC()\n}\n\n// GetInstanceGroup returns the instance group with the specified name","sourceCodeStart":560,"sourceCodeEnd":596,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/template_functions.go#L560-L596","documentation":"A nil-check guard in TaskKey: the caller passed a nil fi.CloudupTask (nil interface or nil pointer stored in the interface) to the helper that builds the canonical \"TypeName/name\" map key. It fires before any type assertion, so a nil task never reaches the HasName check.","triggerScenarios":"Thrown at upup/pkg/fi/cloudup/template_functions.go:578 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the caller to pass a non-nil task; typically a task lookup or construction returned nil and the error was ignored","Check for nil at the call site before invoking TaskKey","If using Task helpers from templates, verify the referenced task exists (see Task/\"task not found\")"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}