{"record":{"id":"525741f85aa97425","repo":"anomalyco/sst","slug":"failed-to-copy-file-contents-w","errorCode":null,"errorMessage":"failed to copy file contents: %w","messagePattern":"failed to copy file contents: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runtime/python/python.go","lineNumber":411,"sourceCode":"func copyFile(src, dst string) error {\n\tif err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil {\n\t\treturn fmt.Errorf(\"failed to create directory for %s: %w\", dst, err)\n\t}\n\n\tsrcFile, err := os.Open(src)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to open source file: %w\", err)\n\t}\n\tdefer srcFile.Close()\n\n\tdstFile, err := os.Create(dst)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create destination file: %w\", err)\n\t}\n\tdefer dstFile.Close()\n\n\tif _, err := io.Copy(dstFile, srcFile); err != nil {\n\t\treturn fmt.Errorf(\"failed to copy file contents: %w\", err)\n\t}\n\n\treturn nil\n}\n\n// skipContent skips __pycache__, .pyc files, and anything matching isIgnored.\nfunc skipContent(relPath string, info os.FileInfo) bool {\n\treturn isIgnored(relPath)\n}\n\n// skipBuildArtifacts skips only dirs that would break workspace package builds.\n// Preserves metadata files (pyproject.toml, etc.) needed by uv pip install.\nfunc skipBuildArtifacts(_ string, info os.FileInfo) bool {\n\tif !info.IsDir() {\n\t\treturn false\n\t}\n\tname := info.Name()\n\treturn name == \"__pycache__\" || name == \".venv\" || name == \"node_modules\" || name == \".git\"","sourceCodeStart":393,"sourceCodeEnd":429,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/pkg/runtime/python/python.go#L393-L429","documentation":"copyFile wraps io.Copy failures (reading src and writing dst streams) with this message. After both files open successfully, the actual byte transfer failed — typically a read error on the source or a write error (disk full, I/O error) on the destination. It is thrown from the same Python runtime copy helper used across build, packaging, and dev sync.","triggerScenarios":"io.Copy(dstFile, srcFile) errors during copyFile: source file unreadable mid-read (removed, changed permissions, device error) or destination write fails (disk full, quota, I/O error). Reached from ensureDockerfile, flattenPackageToRoot, copySourceFilesSimple, copyDependencyPackages, Run, and syncPythonFiles.","commonSituations":"Source file deleted or truncated by a watcher/build race while dev sync is copying; filesystem quota or full disk on the build output volume; networked filesystem (NFS/EFS) hiccup; source is a special file (device/fifo) that errors on read.","solutions":["Check free disk space and quota on the output volume","Re-run the deploy/dev sync — transient FS races often resolve on retry","Verify the source file is a regular readable file (not a fifo/device/symlink to something unreadable)","Inspect the wrapped error text to distinguish read vs write side failure"],"exampleFix":"// before\n_, err = io.Copy(dstFile, srcFile)\n// after\nif fi, statErr := os.Stat(src); statErr == nil && !fi.Mode().IsRegular() {\n\treturn fmt.Errorf(\"skipping non-regular file: %s\", src)\n}\n_, err = io.Copy(dstFile, srcFile)","handlingStrategy":"retry","validationCode":"func regularReadable(path string) error {\n\tfi, err := os.Stat(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !fi.Mode().IsRegular() {\n\t\treturn fmt.Errorf(\"not a regular file: %s\", path)\n\t}\n\tf, err := os.Open(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn f.Close()\n}","typeGuard":null,"tryCatchPattern":"if err := sstBuild(); err != nil {\n\tif strings.Contains(err.Error(), \"failed to copy file contents\") {\n\t\t// free disk space / re-run; transient FS races typically clear on retry\n\t}\n}","preventionTips":["Ensure adequate free space on the output volume","Avoid concurrent processes (formatters, package managers) mutating source files during sync","Verify source files are regular readable files, not fifos/devices","Retry once on transient I/O failures before failing the deploy"],"tags":["go","filesystem","io","build"],"backgroundTag":"file-copy-failed","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}