{"record":{"id":"b5c353bb266f5db4","repo":"apache/beam","slug":"error-in-creating-jar-s-w","errorCode":null,"errorMessage":"error in creating jar %s: %w","messagePattern":"error in creating jar (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go","lineNumber":131,"sourceCode":"\t\tstrings.Contains(url, \"maven.google.com\") ||\n\t\tstrings.Contains(url, \"maven-central.storage-download.googleapis.com\") {\n\t\tlog.Printf(\"WARNING: Downloading JAR file from public repository: %s. \"+\n\t\t\t\"This may pose security risks or cause instability due to repository availability. Consider pre-staging dependencies or using private mirrors.\", url)\n\t}\n\n\tresp, err := http.Get(string(url))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != 200 {\n\t\treturn \"\", fmt.Errorf(\"failed to connect to %v: received non 200 response code, got %v\", url, resp.StatusCode)\n\t}\n\n\tfile, err := os.Create(jarPath)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error in creating jar %s: %w\", jarPath, err)\n\t}\n\n\t_, err = io.Copy(file, resp.Body)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error in coping file %s inside jar %s: %w\", file.Name(), jarPath, err)\n\t}\n\n\treturn jarPath, nil\n}\n\nfunc validatePath(dest, filename string) (string, error) {\n\tdestPath := filepath.Join(dest, filename)\n\tcleanDest := filepath.Clean(dest)\n\tcleanPath := filepath.Clean(destPath)\n\n\trel, err := filepath.Rel(cleanDest, cleanPath)\n\tif err != nil || strings.HasPrefix(rel, \"..\"+string(filepath.Separator)) || rel == \"..\" {\n\t\treturn \"\", fmt.Errorf(\"file path %q is outside destination directory %q\", filename, dest)","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go#L113-L149","documentation":"After a successful HTTP 200 response, getLocalJar creates the local destination file with os.Create(jarPath). This error wraps any failure of that file creation, meaning the jar could not be written at the computed jarPath. It always carries the underlying OS error (permission, nonexistent directory, disk full, etc.) via %w.","triggerScenarios":"os.Create(jarPath) fails during getLocalJar: the cache directory does not exist, is read-only, or is owned by another user.","commonSituations":"Running in a container as non-root while the jar path points to a root-owned directory; HOME unset so the default cache path resolves badly; disk quota exceeded on CI runners.","solutions":["Create the parent directory of jarPath (mkdir -p) and ensure it is writable by the running user.","Check disk space/quota with df on the target filesystem.","Point the jar destination to a writable location (e.g. $TMPDIR or a mounted volume).","Read the wrapped cause (%w) to identify the exact OS-level reason."],"exampleFix":"// before\njarPath, err := expansionx.MakeJar(ctx, url, destDir) // destDir missing\n// after\nif err := os.MkdirAll(destDir, 0700); err != nil {\n    return err\n}\njarPath, err := expansionx.MakeJar(ctx, url, destDir)","handlingStrategy":"validation","validationCode":"dir := filepath.Dir(jarPath)\nif err := os.MkdirAll(dir, 0700); err != nil {\n    return fmt.Errorf(\"cannot create jar dir %s: %w\", dir, err)\n}\nif err := unix.Access(dir, unix.W_OK); err != nil {\n    return fmt.Errorf(\"jar dir %s not writable: %v\", dir, err)\n}","typeGuard":null,"tryCatchPattern":"jarPath, err := expansionx.MakeJar(ctx, url, dest)\nif err != nil {\n    var pe *fs.PathError\n    if errors.As(errors.Unwrap(err), &pe) {\n        log.Printf(\"jar write failed at %s: %v\", pe.Path, pe.Err)\n    }\n    return err\n}","preventionTips":["Pre-create the jar cache directory with correct ownership before running pipelines.","Run workers as a user with write access to the configured cache path.","Monitor disk space/quota on CI and worker machines.","Point cache paths at guaranteed-writable volumes (e.g. $TMPDIR)."],"tags":["go","filesystem","file-write","permissions"],"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"}