{"record":{"id":"0dfd11e1d6b75162","repo":"apache/beam","slug":"error-writing-ta-manifest-file-w","errorCode":null,"errorMessage":"error writing ta manifest file: %w","messagePattern":"error writing ta manifest file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go","lineNumber":299,"sourceCode":"\n\ttmpDir := filepath.Join(cacheDir, \"tmpDir\")\n\n\tif err := extractJar(mainJar, tmpDir); err != nil {\n\t\treturn \"\", fmt.Errorf(\"error in extractJar(): %w\", err)\n\t}\n\n\tmanifest, err := os.ReadFile(tmpDir + \"/META-INF/MANIFEST.MF\")\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error readingf: %w\", err)\n\t}\n\n\t// trim the empty lines present at the end of MANIFEST.MF file.\n\tmanifestLines := strings.Split(string(manifest), \"\\n\")\n\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)","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go#L281-L317","documentation":"After rewriting the manifest with a Class-Path entry, MakeJar writes it back to tmpDir/META-INF/MANIFEST.MF with os.WriteFile and wraps any failure as \"error writing ta manifest file\" (typo for 'the'). It indicates the rewritten manifest could not be persisted, so the JAR would be repacked incorrectly or incompletely.","triggerScenarios":"os.WriteFile fails because tmpDir/META-INF became read-only, the directory was deleted, the disk is full, or permission bits (0660) conflict with the filesystem (e.g. root-owned tmpDir).","commonSituations":"Running under a different user than the one who extracted the JAR; read-only container filesystem; SELinux/AppArmor restrictions on the cache location; disk quota exceeded.","solutions":["Check and fix write permissions on tmpDir and tmpDir/META-INF.","Free disk space / raise quota on the volume holding cacheDir.","Re-extract the JAR (remove cacheDir/tmpDir) so META-INF exists before the write.","Point the cache at a writable directory (set BEAM_HOME or run with a user that owns cacheDir)."],"exampleFix":"// before\nif err = os.WriteFile(tmpDir+\"/META-INF/MANIFEST.MF\", []byte(classpathString), 0660); err != nil {\n    return \"\", fmt.Errorf(\"error writing ta manifest file: %w\", err)\n}\n// after: ensure target dir exists and is writable first\nos.MkdirAll(tmpDir+\"/META-INF\", 0755)\nos.Chmod(tmpDir+\"/META-INF/MANIFEST.MF\", 0660) // only if file pre-exists\nif err = os.WriteFile(tmpDir+\"/META-INF/MANIFEST.MF\", []byte(classpathString), 0660); err != nil {\n    return \"\", fmt.Errorf(\"error writing manifest file: %w\", err)\n}","handlingStrategy":"validation","validationCode":"metaDir := filepath.Join(tmpDir, \"META-INF\")\nif info, err := os.Stat(metaDir); err != nil || !info.IsDir() {\n    return errors.New(\"META-INF dir missing or not writable\")\n}\nif err := unix.Access(metaDir, unix.W_OK); err != nil {\n    return fmt.Errorf(\"no write access to %s: %w\", metaDir, err)\n}","typeGuard":"func isWriteDenied(err error) bool {\n    return errors.Is(err, fs.ErrPermission)\n}","tryCatchPattern":"jar, err := expansionx.MakeJar(ctx, target, repo, version)\nif err != nil && strings.Contains(err.Error(), \"manifest file\") {\n    return fmt.Errorf(\"cache dir not writable, set a writable cache: %w\", err)\n}","preventionTips":["Point the cache at a directory writable by the service user.","Watch disk quota/usage on the cache volume.","Avoid read-only container filesystems for the cache path."],"tags":["go","manifest","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"}