slimtoolkit/slim · error
couldn't unambiguously identify workload in cluster
Error message
couldn't unambiguously identify workload in cluster
What it means
findInCluster requires the workload query to resolve to exactly one resource. If more than one info matches, the tool cannot tell which to attach to and returns this ambiguity error (companion to "couldn't find workload in cluster").
Source
Thrown at pkg/app/master/kubernetes/workload.go:183
namespace = namespaceDefault
}
infos, err := f.resourceBuilderFn().
WithScheme(scheme.Scheme, scheme.Scheme.PrioritizedVersionsAllGroups()...).
NamespaceParam(namespace).
SingleResourceType().
ResourceTypeOrNameArgs(true, target.Workload).
Do().
Infos()
if err != nil {
return nil, err
}
if len(infos) == 0 {
return nil, errors.New("couldn't find workload in cluster")
}
if len(infos) > 1 {
return nil, errors.New("couldn't unambiguously identify workload in cluster")
}
return infos[0], nil
}
View on GitHub (pinned to 81940d17fa)
Solutions
- Specify the exact namespace along with the workload name
- Use a unique workload name or narrower selector
- Remove/rename duplicate workloads that share the same identity
Example fix
// before --target my-app // after --target staging/my-app // disambiguate with namespace
Defensive patterns
Strategy: validation
Validate before calling
deps, _ := clientset.AppsV1().Deployments("" /* all ns */).List(ctx, metav1.ListOptions{})
count := 0
for _, d := range deps.Items { if d.Name == workload { count++ } }
if count > 1 { return fmt.Errorf("workload %s matches %d resources; specify namespace", workload, count) } Try / catch
info, err := findInCluster(ctx, target)
if err != nil && strings.Contains(err.Error(), "unambiguously") {
return fmt.Errorf("qualify the target with its namespace: %w", err)
} Prevention
- Always pass namespace with the workload name
- Avoid duplicate/canary deployments sharing the same name
- Use narrowly scoped selectors
When it happens
Trigger: Calling findInCluster when 2+ resources (e.g. multiple deployments or pods) match the workload name/selector in the cluster.
Common situations: Same-named workloads in multiple namespaces with namespace not specified; duplicated deployments (e.g. blue/green or canary copies); selectors too broad.
Related errors
- unexpected - more than one target pod found
- couldn't find workload in cluster
- Pod terminated
- Pod not running
- Container terminated
AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31).
Data as JSON: /api/errors/91c64eee9404889e.
Report an issue: GitHub.