{"record":{"id":"bf2de5bd63fd7824","repo":"apache/answer","slug":"failed-to-copy-file-contents-from-s-to-s-w","errorCode":null,"errorMessage":"failed to copy file contents from %s to %s: %w","messagePattern":"failed to copy file contents from (.+?) to (.+?): %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cli/build.go","lineNumber":550,"sourceCode":"\t\t} else {\n\t\t\t// Open the source file\n\t\t\tsrcFile, err := sourceFs.Open(srcPath)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to open source file %s: %w\", srcPath, err)\n\t\t\t}\n\t\t\tdefer srcFile.Close()\n\n\t\t\t// Create the destination file\n\t\t\tdstFile, err := os.Create(dstPath)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to create destination file %s: %w\", dstPath, err)\n\t\t\t}\n\t\t\tdefer dstFile.Close()\n\n\t\t\t// Copy the file contents\n\t\t\t_, err = io.Copy(dstFile, srcFile)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to copy file contents from %s to %s: %w\", srcPath, dstPath, err)\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t})\n\n\treturn err\n}\n\n// format plugins dir name from dash to underline\nfunc formatUIPluginsDirName(dirPath string) {\n\tentries, err := os.ReadDir(dirPath)\n\tif err != nil {\n\t\tfmt.Printf(\"read ui plugins dir failed: [%s] %s\\n\", dirPath, err)\n\t\treturn\n\t}\n\tfor _, entry := range entries {\n\t\tif !entry.IsDir() || !strings.Contains(entry.Name(), \"-\") {","sourceCodeStart":532,"sourceCodeEnd":568,"githubUrl":"https://github.com/apache/answer/blob/3b9f1370612e690a0b7f230f05e688930db4c6d3/internal/cli/build.go#L532-L568","documentation":"Returned by the copy helper in internal/cli/build.go when io.Copy(dstFile, srcFile) fails after both files were opened. This means an I/O error occurred mid-transfer: a read failure on the source, a write failure on the destination (disk full, quota exceeded), or a close-time flush error. The wrapped error identifies which side failed.","triggerScenarios":"Disk is full or quota exceeded while writing dstPath; source file shrinks or becomes unreadable during copy; I/O error on the underlying device; rare short-write/pipe errors on network-mounted filesystems.","commonSituations":"Docker/container image builds exhausting disk space; copying large embedded assets to a nearly-full volume; NFS/EFS mounts dropping mid-copy in CI environments.","solutions":["Check free disk space on the destination volume (df -h) — 'no space left on device' is the most common wrapped error","Re-run the operation; transient I/O errors on network mounts often resolve on retry","Check the source file's integrity/readability and the destination device health (dmesg for I/O errors)","If dstFile is buffered, ensure error handling also covers dstFile.Sync()/Close() results"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// preflight: check free space on destination before copying\nout, err := exec.Command(\"df\", \"-h\", targetDir).Output()\nif err != nil {\n    log.Printf(\"could not check disk space: %v\", err)\n} else {\n    fmt.Println(string(out))\n}","typeGuard":null,"tryCatchPattern":"for attempt := 0; attempt < 3; attempt++ {\n    if err := copyFile(srcPath, dstPath); err == nil {\n        break\n    } else if attempt == 2 {\n        return fmt.Errorf(\"copy from %s to %s failed after retries: %w\", srcPath, dstPath, err)\n    }\n    time.Sleep(time.Duration(attempt+1) * time.Second)\n}","preventionTips":["Monitor disk space on the destination volume before large asset copies","Use fsync/Close error checking so buffered write failures surface","Avoid copying large trees over flaky network mounts; stage locally first"],"tags":["go","filesystem","io","disk-space"],"backgroundTag":"no-space-left-on-device","analyzedSha":"3b9f1370612e690a0b7f230f05e688930db4c6d3","analyzedAt":"2026-09-05T18:18:39.533Z","contentChangedAt":"2026-09-05T18:18:39.533Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}