{"record":{"id":"a19c62352f74a362","repo":"flipped-aurora/gin-vue-admin","slug":"error-a19c62","errorCode":null,"errorMessage":"自动代码任务包含重复目标","messagePattern":"自动代码任务包含重复目标","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/service/system/auto_code_task.go","lineNumber":23,"sourceCode":"\t\"encoding/hex\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io/fs\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"sort\"\n\t\"strings\"\n)\n\nconst (\n\tautoCodeStagingPrefix = \".autocode-staging-\"\n\tautoCodeTaskBackend   = \"backend\"\n\tautoCodeTaskFrontend  = \"frontend\"\n)\n\nvar (\n\terrAutoCodeFileConflict    = errors.New(\"自动代码目标文件已被外部修改\")\n\terrAutoCodeDuplicateTarget = errors.New(\"自动代码任务包含重复目标\")\n)\n\ntype autoCodeTaskLayout struct {\n\troot       string\n\tserverRoot string\n\twebRoot    string\n}\n\ntype autoCodeFileTask struct {\n\tlayout     autoCodeTaskLayout\n\tstagingDir string\n\tfiles      []autoCodeTaskFile\n}\n\ntype autoCodeTaskFile struct {\n\tTargetPath    string\n\tKind          string\n\tExisted       bool","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/service/system/auto_code_task.go#L5-L41","documentation":"errAutoCodeDuplicateTarget is returned by prepareAutoCodeFileTask when the generated task contains two entries that resolve to the same target file path (or equivalent duplicates). Committing such a task would write the same file twice with possibly different content, so preparation fails fast.","triggerScenarios":"A create/preview request whose template outputs map onto the same destination — e.g. duplicated template entries, a package/abbreviation combination colliding paths, or a request listing the same file twice (see TestPrepareAutoCodeFileTaskRejectsEquivalentDuplicateTargets).","commonSituations":"Custom templates duplicating output paths; autocode payloads with overlapping struct/package settings; merged requests where frontend and backend file sets intersect.","solutions":["Review the request's package/abbreviation/template settings so each generated file maps to a unique path.","Deduplicate the target list before preparing the task.","Fix custom templates that emit the same output path more than once.","Split the request into separate tasks if distinct content must land in the same file."],"exampleFix":"// before: two templates write server/api/v1/foo.go\noutputs: [\"server/api/v1/foo.go\", \"server/api/v1/foo.go\"]\n// after\noutputs: [\"server/api/v1/foo.go\"]","handlingStrategy":"validation","validationCode":"seen := map[string]bool{}\nfor _, p := range targetPaths {\n    if seen[p] {\n        return fmt.Errorf(\"重复目标路径: %s\", p)\n    }\n    seen[p] = true\n}\n// safe to prepare the task","typeGuard":null,"tryCatchPattern":"task, err := prepareAutoCodeFileTask(layout, req)\nif err != nil {\n    if errors.Is(err, errAutoCodeDuplicateTarget) {\n        return fmt.Errorf(\"请检查模板输出/请求参数, 去除重复目标文件: %w\", err)\n    }\n    return err\n}","preventionTips":["Deduplicate template output paths before sending autocode requests.","Ensure package/abbreviation combinations yield unique file paths.","Audit custom templates for repeated output declarations.","Split conflicting content into separate tasks or merge templates."],"tags":["autocode","validation","duplicate","task"],"backgroundTag":"duplicate-target-path","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}