{"record":{"id":"a3be93332e586bc0","repo":"owasp-amass/amass","slug":"failed-to-copy-the-file-s-v","errorCode":null,"errorMessage":"failed to copy the file %s: %v","messagePattern":"failed to copy the file (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/file.go","lineNumber":57,"sourceCode":"\t\t\t// If the file already exists, skip creating it\n\t\t\tcontinue\n\t\t}\n\n\t\tfile, err := resources.GetResourceFile(filename)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to obtain the embedded file %s: %v\", filename, err)\n\t\t}\n\t\tdefer func() { _ = file.Close() }()\n\n\t\t// Create the default config file in the specified directory\n\t\toutFile, err := os.Create(filepath)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to create the output file %s: %v\", filepath, err)\n\t\t}\n\t\tdefer func() { _ = outFile.Close() }()\n\n\t\tif _, err := io.Copy(outFile, file); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to copy the file %s: %v\", filepath, err)\n\t\t}\n\t}\n\treturn nil\n}\n","sourceCodeStart":39,"sourceCodeEnd":62,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/internal/tools/file.go#L39-L62","documentation":"After creating the destination file, CreateDefaultConfigFiles copies the embedded file contents with io.Copy. This error means the copy operation failed — either writing to the destination file or (less likely) reading the embedded source failed mid-stream.","triggerScenarios":"Disk becomes full while writing, the destination file descriptor hits an I/O error (bad sector, quota exceeded, network mount dropout), or the file is truncated/removed concurrently.","commonSituations":"Small disk partitions or container quota limits exhausted during initialization; NFS/EBS volumes losing connectivity mid-copy; concurrent runs racing on the same output directory.","solutions":["Check free disk space and any quota (df -h, du on the volume)","Re-run the tool; if a partially written config remains, delete it first (os.Stat with the exists check will skip a truncated file otherwise)","Avoid running multiple instances concurrently against the same output directory","Check dmesg/journal for filesystem I/O errors and move the output directory to healthy storage"],"exampleFix":"// before\nif _, err := io.Copy(outFile, file); err != nil { return ... }\n// after\nif _, err := io.Copy(outFile, file); err != nil {\n\toutFile.Close()\n\tos.Remove(filepath) // drop partial file so next run recreates it\n\treturn fmt.Errorf(\"failed to copy the file %s: %v\", filepath, err)\n}","handlingStrategy":"retry","validationCode":"st, err := os.Stat(dirpath)\nif err != nil || !st.IsDir() { return fmt.Errorf(\"output dir unusable\") }\nif us := getDiskFree(dirpath); us < 10*1024*1024 { return fmt.Errorf(\"less than 10MB free\") }","typeGuard":null,"tryCatchPattern":"for attempt := 0; attempt < 2; attempt++ {\n\terr := tools.CreateDefaultConfigFiles(dirpath)\n\tif err == nil { break }\n\tif strings.Contains(err.Error(), \"failed to copy the file\") && attempt == 0 {\n\t\tos.RemoveAll(filepath.Join(dirpath)) // clear partial files\n\t\t_ = tools.CreateOutputDirectory(dirpath)\n\t\tcontinue\n\t}\n\treturn err\n}","preventionTips":["Monitor disk space/quota before running heavy jobs","Do not share an output directory between concurrent tool instances","Remove partial/truncated config files after failed runs","Watch dmesg/journal for I/O errors on the storage backing the output dir"],"tags":["go","io","filesystem","disk"],"backgroundTag":"file-write-failed","analyzedSha":"79299dce87b0085db0f2f4ef3e9c52cccb49f514","analyzedAt":"2026-09-06T08:22:48.198Z","contentChangedAt":"2026-09-06T08:22:48.198Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}