{"record":{"id":"cb325d1fc4f9033f","repo":"kubernetes/kops","slug":"different-types-for-copy-target-s","errorCode":null,"errorMessage":"different types for copy target %s","messagePattern":"different types for copy target (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/assets/assetcopy/copy.go","lineNumber":72,"sourceCode":"\t\t\ttasks[copyImageTask.Name] = copyImageTask\n\t\t}\n\t}\n\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","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/assets/assetcopy/copy.go#L54-L90","documentation":"Copy deduplicates file copy tasks by name (the target file path). If a task name already exists in the map but holds a *CopyImage instead of a *CopyFile (or vice versa), the target is being used for two different task kinds, so Copy aborts with this error.","triggerScenarios":"A file asset's target path equals an image asset's target name within one Copy run, so tasks[name] holds a *CopyImage when a *CopyFile is inserted (or the map contains a non-CopyFile value under that name).","commonSituations":"Misconfigured asset targets where a file destination path collides with an image tag/target string; generated asset lists where the same logical name is reused by different asset types across versions.","solutions":["Make file and image targets occupy distinct namespaces/names so they never collide","Fix the asset configuration that reuses one target name for both a file path and an image target","Regenerate the asset list so each target is produced by exactly one task type"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"names := map[string]string{}\nfor _, t := range allTasks {\n\tif prev, ok := names[t.Name()]; ok && prev != fmt.Sprintf(\"%T\", t) {\n\t\treturn fmt.Errorf(\"pre-check: target %s reused by %s and %s\", t.Name(), prev, fmt.Sprintf(\"%T\", t))\n\t}\n\tnames[t.Name()] = fmt.Sprintf(\"%T\", t)\n}","typeGuard":"func targetIsFreeForFile(tasks map[string]Task, name string) bool {\n\t_, occupied := tasks[name]\n\treturn !occupied\n}","tryCatchPattern":"if err := copy.Run(ctx); err != nil {\n\tif strings.Contains(err.Error(), \"different types for copy target\") {\n\t\treturn fmt.Errorf(\"asset config bug: %w — file and image targets must not share a name\", err)\n\t}\n\treturn err\n}","preventionTips":["Keep image targets and file paths in disjoint name spaces","Review generated asset names for collisions between asset kinds","Avoid reusing one target string for both image tags and file destinations"],"tags":["assets","files","type-conflict"],"backgroundTag":"asset-target-type-conflict","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"}