{"record":{"id":"8dcb7111f01389c5","repo":"apache/beam","slug":"error-in-packjar-w","errorCode":null,"errorMessage":"error in packJar(): %w","messagePattern":"error in packJar\\(\\): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go","lineNumber":313,"sourceCode":"\tmanifestLines = manifestLines[:len(manifestLines)-2]\n\n\tclasspathString := fmt.Sprintf(\"%sClass-Path: %s\\n\", strings.Join(manifestLines, \"\\n\"), strings.Join(relClasspath, \" \"))\n\tif err = os.WriteFile(tmpDir+\"/META-INF/MANIFEST.MF\", []byte(classpathString), 0660); err != nil {\n\t\treturn \"\", fmt.Errorf(\"error writing ta manifest file: %w\", err)\n\t}\n\n\tpath, err := os.Getwd()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"can't get current working directory: %w\", err)\n\t}\n\n\tif err = os.Chdir(tmpDir); err != nil {\n\t\treturn \"\", fmt.Errorf(\"can't change to temp directory %s for creating JAR: %w\", tmpDir, err)\n\t}\n\n\ttmpJar := filepath.Join(cacheDir, \"tmp.jar\")\n\tif err = packJar(\".\", tmpJar); err != nil {\n\t\treturn \"\", fmt.Errorf(\"error in packJar(): %w\", err)\n\t}\n\n\tif err = os.Chdir(path); err != nil {\n\t\treturn \"\", fmt.Errorf(\"can't change to old working directory %s: %w\", path, err)\n\t}\n\n\treturn tmpJar, nil\n}\n\n// GetBeamJar checks a temporary directory for the desired Beam JAR, downloads the\n// appropriate JAR from Maven if not present, then returns the file path to the\n// JAR.\nfunc GetBeamJar(gradleTarget, version string) (string, error) {\n\treturn defaultJarGetter.getJar(gradleTarget, version)\n}\n\nfunc (j *jarGetter) getRepositoryURL() string {\n\treturn string(j.repository)","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go#L295-L331","documentation":"After chdir-ing into tmpDir, MakeJar calls packJar(\".\", tmpJar) to create a zip of the extracted contents at cacheDir/tmp.jar; any packing failure (zip create/write error) is wrapped as \"error in packJar()\".","triggerScenarios":"packJar fails because tmp.jar cannot be created in cacheDir (permissions, disk full), or a file inside tmpDir cannot be read/zipped (disappeared mid-walk, symlink issues, unreadable entries).","commonSituations":"Cache directory not writable by the service user; files added/removed in tmpDir while packing due to concurrent runs; oversized contents exceeding disk quota.","solutions":["Ensure cacheDir is writable and has enough free space.","Stop concurrent processes touching tmpDir, clean it, and retry.","Unwrap the error to identify the specific file that failed to be written/read.","Check for unreadable files/symlinks in tmpDir before packing."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"tmpJar := filepath.Join(cacheDir, \"tmp.jar\")\nif f, err := os.Create(tmpJar); err != nil {\n    return fmt.Errorf(\"cannot write tmp.jar in cacheDir: %w\", err)\n} else {\n    f.Close()\n    os.Remove(tmpJar)\n}","typeGuard":null,"tryCatchPattern":"jar, err := expansionx.MakeJar(ctx, target, repo, version)\nvar pe *fs.PathError\nif err != nil && errors.As(err, &pe) && errors.Is(pe.Err, fs.ErrPermission) {\n    return fmt.Errorf(\"check cacheDir permissions/disk space: %w\", err)\n}","preventionTips":["Ensure adequate free space in cacheDir before starting.","Avoid concurrent runs sharing one cacheDir.","Confirm the service user can create files in cacheDir."],"tags":["go","zip","packjar","file-write"],"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"}