{"record":{"id":"e47c8e270dcf8a42","repo":"apache/beam","slug":"source-path-s-doesn-t-exist-w","errorCode":null,"errorMessage":"source path %s doesn't exist: %w","messagePattern":"source path (.+?) doesn't exist: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go","lineNumber":205,"sourceCode":"\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 {\n\t\t\treturn fmt.Errorf(\"error accesing path %s: %w\", path, err)\n\t\t}\n\t\tfileHeader, err := zip.FileInfoHeader(fileInfo)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error getting FileInfoHeader: %w\", err)\n\t\t}\n\n\t\tif sourceDir != \"\" {\n\t\t\tfileHeader.Name = filepath.Join(sourceDir, strings.TrimPrefix(path, source))","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go#L187-L223","documentation":"packJar failed at os.Stat(source): the directory or file being repacked into the JAR does not exist (or is inaccessible). This happens after the destination jar was already created, so a partial/empty jar file may be left on disk. The underlying os.Stat error is wrapped with the source path.","triggerScenarios":"packJar(source, dest) is called with a source path that was deleted, never created, or is unreadable — e.g. the tmpDir produced by extractJar was removed, or MakeJar was pointed at a mainJar that failed to extract fully.","commonSituations":"Stale or concurrently deleted ~/.beam661bea09-.../tmpDir; another process cleaned the cache mid-run; typo'd path passed to a custom caller of packJar; extractJar failed silently earlier leaving no tmpDir.","solutions":["Verify the source path exists with ls before packing; recreate it (re-run extractJar on the main JAR).","Remove stale tmpDir under the jar cache and retry so extraction recreates it.","Avoid concurrent processes sharing the same jar cache directory.","If calling packJar directly, validate os.Stat(source) yourself first and fail early."],"exampleFix":"// before\npackJar(tmpDir, outJar)\n// after\nif _, err := os.Stat(tmpDir); err != nil {\n    return fmt.Errorf(\"source %s missing: %w\", tmpDir, err)\n}\npackJar(tmpDir, outJar)","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(source); err != nil {\n    return fmt.Errorf(\"source %s unavailable: %w\", source, err)\n}","typeGuard":null,"tryCatchPattern":"if err := packJar(source, dest); err != nil {\n    if errors.Is(err, fs.ErrNotExist) {\n        // recreate source tree (re-run extractJar) and retry once\n    }\n    return err\n}","preventionTips":["Always run extractJar successfully before packJar; check its error.","Never share/mutate the tmpDir from concurrent processes.","Recreate the cache dir rather than assuming it persists across runs.","Validate source existence at the start of MakeJar."],"tags":["go","filesystem","jar","path"],"backgroundTag":"file-not-found","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"}