{"record":{"id":"6064f453e2d63136","repo":"kubernetes/kops","slug":"different-targets-for-same-file-s-s-vs-s","errorCode":null,"errorMessage":"different targets for same file %s: %s vs %s","messagePattern":"different targets for same file (.+?): (.+?) vs (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/assets/assetcopy/copy.go","lineNumber":75,"sourceCode":"\n\tfor _, fileAsset := range fileAssets {\n\t\tif fileAsset.DownloadURL.String() != fileAsset.CanonicalURL.String() {\n\t\t\tcopyFileTask := &CopyFile{\n\t\t\t\tName:       fileAsset.CanonicalURL.String(),\n\t\t\t\tTargetFile: fileAsset.DownloadURL.String(),\n\t\t\t\tSourceFile: fileAsset.CanonicalURL.String(),\n\t\t\t\tSHA:        fileAsset.SHAValue.Hex(),\n\t\t\t\tVFSContext: vfsContext,\n\t\t\t\tCluster:    cluster,\n\t\t\t}\n\n\t\t\tif existing, ok := tasks[copyFileTask.Name]; ok {\n\t\t\t\te, ok := existing.(*CopyFile)\n\t\t\t\tif !ok {\n\t\t\t\t\treturn fmt.Errorf(\"different types for copy target %s\", copyFileTask.Name)\n\t\t\t\t}\n\t\t\t\tif e.TargetFile != copyFileTask.TargetFile {\n\t\t\t\t\treturn fmt.Errorf(\"different targets for same file %s: %s vs %s\", copyFileTask.Name, copyFileTask.TargetFile, e.TargetFile)\n\t\t\t\t}\n\t\t\t\tif e.SHA != copyFileTask.SHA {\n\t\t\t\t\treturn fmt.Errorf(\"different sha for same file %s: %s vs %s\", copyFileTask.Name, copyFileTask.SHA, e.SHA)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ttasks[copyFileTask.Name] = copyFileTask\n\t\t}\n\t}\n\n\tch := make(chan error, 5)\n\tfor i := 0; i < cap(ch); i++ {\n\t\tch <- nil\n\t}\n\n\tgotError := false\n\tnames := make([]string, 0, len(tasks))\n\tfor name := range tasks {","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/assets/assetcopy/copy.go#L57-L93","documentation":"Two *CopyFile tasks sharing the same task name (target key) must also agree on TargetFile; if the existing task's TargetFile differs from the new one's, the same dedup key maps to two different destinations, so Copy fails fast rather than writing to an ambiguous target.","triggerScenarios":"Two FileAssets whose task names collide but whose TargetFile fields differ, added in the same Copy invocation (e.g. assets built from nodeup/manifest assets lists with overlapping names).","commonSituations":"Asset name collisions after upgrading kOps where a file's target path changed but its key did not; templated target paths producing inconsistent values; duplicate entries in fileAssets config with differing destinations.","solutions":["Ensure the task name and TargetFile are derived from the same value so equal names imply equal targets","Remove or rename duplicate file assets that share a name but disagree on destination","Regenerate assets from a single consistent version so target paths match across entries"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"fileTargets := map[string]string{}\nfor _, f := range fileAssets {\n\tif prev, ok := fileTargets[f.Name]; ok && prev != f.TargetFile {\n\t\treturn fmt.Errorf(\"pre-check: task %s maps to targets %s and %s\", f.Name, prev, f.TargetFile)\n\t}\n\tfileTargets[f.Name] = f.TargetFile\n}","typeGuard":"func fileTargetsConsistent(files []FileAsset) bool {\n\tseen := map[string]string{}\n\tfor _, f := range files {\n\t\tif p, ok := seen[f.Name]; ok && p != f.TargetFile {\n\t\t\treturn false\n\t\t}\n\t\tseen[f.Name] = f.TargetFile\n\t}\n\treturn true\n}","tryCatchPattern":"if err := copy.Run(ctx); err != nil {\n\tif strings.Contains(err.Error(), \"different targets for same file\") {\n\t\treturn fmt.Errorf(\"asset config bug: %w — one task name must map to one target path\", err)\n\t}\n\treturn err\n}","preventionTips":["Derive task names directly from the target path so they cannot diverge","Regenerate the full asset list on upgrades instead of mixing old and new entries","Review templated target paths for inconsistent rendering"],"tags":["assets","files","deduplication"],"backgroundTag":"asset-target-mismatch","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"}