{"record":{"id":"78dd930b8b91aaab","repo":"apache/beam","slug":"error-opening-file-s-w","errorCode":null,"errorMessage":"error opening file %s: %w","messagePattern":"error opening file (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go","lineNumber":242,"sourceCode":"\t\t}\n\n\t\tif fileInfo.IsDir() {\n\t\t\tfileHeader.Name += \"/\"\n\t\t} else {\n\t\t\tfileHeader.Method = zip.Deflate\n\t\t}\n\n\t\twriter, err := jarFile.CreateHeader(fileHeader)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error creating jarFile header: %w\", err)\n\t\t}\n\t\tif fileInfo.IsDir() {\n\t\t\treturn nil\n\t\t}\n\n\t\tf, err := os.Open(path)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error opening file %s: %w\", path, err)\n\t\t}\n\t\tdefer f.Close()\n\n\t\tif _, err = io.Copy(writer, f); err != nil {\n\t\t\treturn fmt.Errorf(\"error copying file %s: %w\", path, err)\n\t\t}\n\t\treturn nil\n\t})\n\treturn err\n}\n\n// MakeJar fetches additional classpath JARs and adds it to the classpath of\n// main JAR file and compiles a fresh JAR.\nfunc MakeJar(mainJar string, classpath string) (string, error) {\n\tusr, _ := user.Current()\n\tcacheDir := filepath.Join(usr.HomeDir, jarCache[2:])\n\n\t// fetch jars required in classpath","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go#L224-L260","documentation":"packJar failed to open a file from the source tree (os.Open(path)) after creating its zip header, so its contents cannot be copied into the JAR. The wrapped OS error (usually ENOENT or EACCES) includes the exact path that could not be opened.","triggerScenarios":"Inside the walk callback, a non-directory entry cannot be opened: the file was deleted between Walk's stat and Open, its permissions deny read, it's a special/fifo file, or a symlink target is missing.","commonSituations":"Concurrent cleanup deleting files in tmpDir mid-pack; files extracted with mode 000 or owned by another user; dangling symlinks inside the extracted JAR tree; packing special device files.","solutions":["Fix read permissions on the source tree (chmod -R u+r) or run packing as the file owner.","Remove dangling symlinks / special files from the tree before packing.","Delete tmpDir, re-extract the main JAR, and pack again to eliminate race conditions.","Ensure no other process deletes files from the source directory while MakeJar runs."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if fi.Mode()&0400 == 0 { return fmt.Errorf(\"unreadable file: %s\", path) }\nif fi.Mode()&os.ModeType != 0 && !fi.IsDir() { return fmt.Errorf(\"special file skipped: %s\", path) }","typeGuard":null,"tryCatchPattern":"f, err := os.Open(path)\nif err != nil {\n    var pe *fs.PathError\n    if errors.As(err, &pe) && errors.Is(pe.Err, fs.ErrNotExist) {\n        return nil // or log-and-skip policy for vanished files\n    }\n    return fmt.Errorf(\"error opening file %s: %w\", path, err)\n}","preventionTips":["Freeze the source tree during packing (no concurrent cleanup).","Fix restrictive file modes right after extraction.","Remove dangling symlinks before Walk.","Run extract and pack under the same user."],"tags":["go","filesystem","jar","permissions"],"backgroundTag":"file-open-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"}