{"record":{"id":"91c64eee9404889e","repo":"slimtoolkit/slim","slug":"couldn-t-unambiguously-identify-workload-in-cluste","errorCode":null,"errorMessage":"couldn't unambiguously identify workload in cluster","messagePattern":"couldn't unambiguously identify workload in cluster","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/master/kubernetes/workload.go","lineNumber":183,"sourceCode":"\t\tnamespace = namespaceDefault\n\t}\n\n\tinfos, err := f.resourceBuilderFn().\n\t\tWithScheme(scheme.Scheme, scheme.Scheme.PrioritizedVersionsAllGroups()...).\n\t\tNamespaceParam(namespace).\n\t\tSingleResourceType().\n\t\tResourceTypeOrNameArgs(true, target.Workload).\n\t\tDo().\n\t\tInfos()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif len(infos) == 0 {\n\t\treturn nil, errors.New(\"couldn't find workload in cluster\")\n\t}\n\tif len(infos) > 1 {\n\t\treturn nil, errors.New(\"couldn't unambiguously identify workload in cluster\")\n\t}\n\n\treturn infos[0], nil\n}\n","sourceCodeStart":165,"sourceCodeEnd":188,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/master/kubernetes/workload.go#L165-L188","documentation":"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\").","triggerScenarios":"Calling findInCluster when 2+ resources (e.g. multiple deployments or pods) match the workload name/selector in the cluster.","commonSituations":"Same-named workloads in multiple namespaces with namespace not specified; duplicated deployments (e.g. blue/green or canary copies); selectors too broad.","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"],"exampleFix":"// before\n--target my-app\n// after\n--target staging/my-app // disambiguate with namespace","handlingStrategy":"validation","validationCode":"deps, _ := clientset.AppsV1().Deployments(\"\" /* all ns */).List(ctx, metav1.ListOptions{})\ncount := 0\nfor _, d := range deps.Items { if d.Name == workload { count++ } }\nif count > 1 { return fmt.Errorf(\"workload %s matches %d resources; specify namespace\", workload, count) }","typeGuard":null,"tryCatchPattern":"info, err := findInCluster(ctx, target)\nif err != nil && strings.Contains(err.Error(), \"unambiguously\") {\n  return fmt.Errorf(\"qualify the target with its namespace: %w\", err)\n}","preventionTips":["Always pass namespace with the workload name","Avoid duplicate/canary deployments sharing the same name","Use narrowly scoped selectors"],"tags":["kubernetes","workload","ambiguity"],"backgroundTag":"ambiguous-resource-selector","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}