{"record":{"id":"21a9af1367372491","repo":"apache/beam","slug":"error-creating-jar-packjar-s-s-w","errorCode":null,"errorMessage":"error creating jar packJar(%s,%s)=%w","messagePattern":"error creating jar packJar\\((.+?),(.+?)\\)=%w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go","lineNumber":196,"sourceCode":"\t\tdefer sf.Close()\n\n\t\tdf, err := os.OpenFile(fileName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0777)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error opening destination file %s: %w\", fileName, err)\n\t\t}\n\t\tdefer df.Close()\n\n\t\tif _, err := io.Copy(df, sf); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc packJar(source, dest string) error {\n\tjar, err := os.Create(dest)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error creating jar packJar(%s,%s)=%w\", source, dest, err)\n\t}\n\tdefer jar.Close()\n\n\tjarFile := zip.NewWriter(jar)\n\tdefer jarFile.Close()\n\n\tfileInfo, err := os.Stat(source)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"source path %s doesn't exist: %w\", source, err)\n\t}\n\n\tvar sourceDir string\n\tif fileInfo.IsDir() {\n\t\tsourceDir = filepath.Base(source)\n\t}\n\n\terr = filepath.Walk(source, func(path string, fileInfo os.FileInfo, err error) error {\n\t\tif err != nil {","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go#L178-L214","documentation":"packJar could not create the destination JAR file itself via os.Create(dest). This is the first step of repackaging the extracted JAR plus new classpath entries, so any failure here aborts MakeJar before any content is written. The wrapped OS error names both the source tree and the target path.","triggerScenarios":"os.Create(dest) fails because the destination directory does not exist or is unwritable, the path points to a directory, or disk/permission limits (EACCES, ENOENT, EISDIR, ENOSPC) apply.","commonSituations":"$HOME/.beam661bea09-... cache dir deleted or mounted read-only between extract and pack steps; a directory named like the output jar already exists; container running with read-only filesystem or as wrong user.","solutions":["Ensure the destination directory for the output jar exists and is writable (create/chmod/chown it).","Check the dest path does not resolve to an existing directory; remove or rename it.","Free disk space if df shows a full volume.","Verify the process user can write to $HOME where the Beam jar cache lives."],"exampleFix":"// before: read-only HOME in container\nENV HOME=/nonexistent\n// after: provide a writable home for the jar cache\nENV HOME=/home/beam\nRUN mkdir -p /home/beam && chown beam:beam /home/beam","handlingStrategy":"validation","validationCode":"destDir := filepath.Dir(dest)\nif info, err := os.Stat(destDir); err != nil || !info.IsDir() {\n    os.MkdirAll(destDir, 0700)\n}\nif fi, err := os.Stat(dest); err == nil && fi.IsDir() {\n    return fmt.Errorf(\"dest %s is a directory\", dest)\n}\nprobe, err := os.CreateTemp(destDir, \".writecheck\")\nif err != nil { return err }\nprobe.Close(); os.Remove(probe.Name())","typeGuard":null,"tryCatchPattern":"jar, err := os.Create(dest)\nif err != nil {\n    return fmt.Errorf(\"error creating jar packJar(%s,%s)=%w\", source, dest, err)\n}","preventionTips":["Guarantee a writable HOME/volume for the jar cache in deployment configs.","Avoid read-only container root filesystems for cache paths.","Pre-create and chown the cache directory at image build/startup time.","Clean up partial outputs before retrying."],"tags":["go","filesystem","jar"],"backgroundTag":"file-write-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}