{"record":{"id":"63ccc7c5a786f1e9","repo":"slimtoolkit/slim","slug":"found-more-than-1-workload-s-s-match-in-the-su","errorCode":null,"errorMessage":"found more than 1 workload '%s/%s' match in the supplied manifests","messagePattern":"found more than 1 workload '(.+?)/(.+?)' match in the supplied manifests","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/master/kubernetes/manifests.go","lineNumber":94,"sourceCode":"\tfor _, info := range ms.infos {\n\t\tif info.Mapping.GroupVersionKind.GroupKind() != mapping.GroupVersionKind.GroupKind() {\n\t\t\tcontinue\n\t\t}\n\t\tif info.Name != name {\n\t\t\tcontinue\n\t\t}\n\t\tif target.Namespace != \"\" && target.Namespace != info.Namespace {\n\t\t\tcontinue\n\t\t}\n\n\t\tmatches = append(matches, info)\n\t}\n\n\tif len(matches) == 0 {\n\t\treturn nil, nil\n\t}\n\tif len(matches) > 1 {\n\t\treturn nil, fmt.Errorf(\"found more than 1 workload '%s/%s' match in the supplied manifests\", target.Namespace, name)\n\t}\n\n\treturn matches[0], nil\n}\n\nfunc (ms *Manifests) Apply(ctx context.Context, predicate func(info *resource.Info) bool) error {\n\tfor _, info := range ms.infos {\n\t\tif !predicate(info) {\n\t\t\tcontinue\n\t\t}\n\n\t\tif err := ms.client.CreateOrUpdate(ctx, info); err != nil {\n\t\t\t// TODO: consider partial applying\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/master/kubernetes/manifests.go#L76-L112","documentation":"Manifests.Find looks up a workload (namespace/name) in the set of loaded Kubernetes manifests. If more than one resource info matches the target namespace and name, the lookup is ambiguous and Find returns this error instead of guessing. It protects against applying/inspecting the wrong workload.","triggerScenarios":"Calling Find with a target whose namespace/name appears in multiple resources across the supplied manifest files (or duplicates within one file) — e.g. the same Deployment defined twice, or manifests merged from overlapping files.","commonSituations":"Passing several manifest files that each define the same workload; copy-pasted resources across overlays; kustomize output where a workload is duplicated across bases and patches; targeting by name in manifests with same-name resources in namespaces that got flattened.","solutions":["Remove or rename the duplicate workload definitions so namespace/name is unique across all supplied manifests.","Check which files contain duplicates: kubectl get -f <files> or grep for the workload name/kind.","Narrow the manifest set passed to slim to only the files needed for the target workload.","Qualify the target with an explicit namespace so matching is unambiguous."],"exampleFix":"# before: duplicates across files\nslim k8s --target-deployment app --manifests base.yaml,overlay.yaml  # both define default/app\n# after: single source of truth\nslim k8s --target-deployment app --manifests rendered.yaml","handlingStrategy":"validation","validationCode":"// ensure namespace/name is unique across supplied manifests before Find\nnames := map[string]int{}\nfor _, info := range infos {\n    key := info.Namespace + \"/\" + info.Name\n    names[key]++\n    if names[key] > 1 {\n        log.Fatalf(\"duplicate workload %s in supplied manifests\", key)\n    }\n}","typeGuard":null,"tryCatchPattern":"w, err := manifests.Find(ctx, ns, name)\nif err != nil && strings.Contains(err.Error(), \"found more than 1 workload\") {\n    return fmt.Errorf(\"deduplicate %s/%s across --manifests files: %w\", ns, name, err)\n}","preventionTips":["Render kustomize/helm output once into a single file instead of passing overlapping sources.","Grep supplied manifests for the target name/kind before running slim.","Give each workload a unique namespace/name combination."],"tags":["kubernetes","manifests","validation"],"backgroundTag":"duplicate-resource-manifest","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}