apache/beam · error
error copying file
Error message
error copying file %s: %w
What it means
io.Copy(writer, f) failed while streaming a source file's contents into the zip entry, meaning either reading the source file or (more often) writing to the zip stream failed mid-copy. The error carries the source path; the underlying cause is wrapped from io.Copy.
Solutions
- Free disk space on the output volume and re-run MakeJar/packJar.
- Verify the failing file is readable and not corrupt (cmp it against the original JAR entry; re-extract if needed).
- Check volume quota and filesystem health if the wrapped error is a write error.
- Retry from a clean state: remove the partial output jar and tmpDir, then re-extract and pack.
Defensive patterns
Strategy: retry
Validate before calling
if fi, err := os.Stat(path); err != nil || fi.Size() == 0 && expectedSize > 0 { return fmt.Errorf("source file bad: %s", path) } Try / catch
if _, err = io.Copy(writer, f); err != nil {
return fmt.Errorf("error copying file %s: %w", path, err)
}
// caller: on ENOSPC/EIO, clean partial jar + tmpDir and retry MakeJar once Prevention
- Keep enough free disk for the fully repacked JAR.
- Verify extracted files against the source JAR checksums.
- Use local (not network) storage for tmpDir and output.
- Retry the whole MakeJar flow from a clean cache after I/O errors.
When it happens
Trigger: During packJar's walk callback, io.Copy between the opened source file and the zip entry writer errors: source read error (EIO, truncated file) or destination write error (ENOSPC on the volume holding the output jar).
Common situations: Full or failing disk while repacking a large JAR; corrupted/truncated file in the extracted tree; network storage dropping mid-read; quota exceeded on the destination volume.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- error creating jarFile header
- error opening destination file
- error opening source file
- bucket must not be empty
- chunk write failed
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/2ffe2cd6a6c2999e.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go:247
fileHeader.Method = zip.Deflate
}
writer, err := jarFile.CreateHeader(fileHeader)
if err != nil {
return fmt.Errorf("error creating jarFile header: %w", err)
}
if fileInfo.IsDir() {
return nil
}
f, err := os.Open(path)
if err != nil {
return fmt.Errorf("error opening file %s: %w", path, err)
}
defer f.Close()
if _, err = io.Copy(writer, f); err != nil {
return fmt.Errorf("error copying file %s: %w", path, err)
}
return nil
})
return err
}
// MakeJar fetches additional classpath JARs and adds it to the classpath of
// main JAR file and compiles a fresh JAR.
func MakeJar(mainJar string, classpath string) (string, error) {
usr, _ := user.Current()
cacheDir := filepath.Join(usr.HomeDir, jarCache[2:])
// fetch jars required in classpath
classpaths := strings.Split(classpath, " ")
classpathJars := []string{}
for _, jar := range classpaths {
path := expandJar(jar)
if j, err := getLocalJar(path); err == nil {View on GitHub (pinned to 12126d8942)