kubernetes/kops · error
task %T does not implement HasName
Error message
task %T does not implement HasName
What it means
A type-assertion guard in TaskKey: the given task's concrete Go type does not implement the fi.HasName interface (no GetName() method). TaskKey requires a name to build the map key, so anonymous/nameless task types cannot be keyed and are rejected here.
Source
Thrown at upup/pkg/fi/cloudup/template_functions.go:582
}
}
sort.Strings(keys)
matches := make([]fi.CloudupTask, 0, len(keys))
for _, key := range keys {
matches = append(matches, tasks[key])
}
return matches, nil
}
// TaskKey returns the canonical task key used in the task map.
func (tf *TemplateFunctions) TaskKey(task fi.CloudupTask) (string, error) {
if task == nil {
return "", fmt.Errorf("task is nil")
}
hasName, ok := task.(fi.HasName)
if !ok {
return "", fmt.Errorf("task %T does not implement HasName", task)
}
name := fi.ValueOf(hasName.GetName())
if name == "" {
return "", fmt.Errorf("task %T did not have a name", task)
}
return fi.TypeNameForTask(task) + "/" + name, nil
}
// SharedVPC is a simple helper function which makes the templates for a shared VPC clearer
func (tf *TemplateFunctions) SharedVPC() bool {
return tf.Cluster.SharedVPC()
}
// GetInstanceGroup returns the instance group with the specified name
func (tf *TemplateFunctions) GetInstanceGroup(name string) (*kops.InstanceGroup, error) {
ig := tf.KopsModelContext.FindInstanceGroup(name)
if ig == nil {
return nil, fmt.Errorf("InstanceGroup %q not found", name)View on GitHub (pinned to 4c8573c808)
Solutions
- Give the task type a GetName() *string method so it satisfies fi.HasName
- If the task is legitimately nameless, do not pass it to TaskKey; use a different lookup strategy
- Check for a value vs pointer receiver mismatch — the method may exist on *T while a T was passed
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at upup/pkg/fi/cloudup/template_functions.go:582 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/d710479e42bc9d94.
Report an issue: GitHub.