apache/beam · error

error readingf

Error message

error readingf: %w

What it means

MakeJar reads tmpDir/META-INF/MANIFEST.MF after extracting the JAR and wraps any os.ReadFile failure as "error readingf: %w" (note the typo "readingf"). It means the extracted JAR did not contain a readable MANIFEST.MF at the expected location.

Solutions

  1. Confirm the JAR actually contains META-INF/MANIFEST.MF (unzip -l mainJar).
  2. Remove the stale cache/tmpDir and re-download the JAR, then retry.
  3. Check tmpDir permissions and that no concurrent process deletes it.
  4. If the JAR legitimately lacks a manifest, create it rather than using MakeJar, or package a JAR that includes one.
Defensive patterns

Strategy: validation

Validate before calling

zr, err := zip.OpenReader(mainJar)
if err != nil {
    return err
}
defer zr.Close()
hasManifest := false
for _, f := range zr.File {
    if f.Name == "META-INF/MANIFEST.MF" {
        hasManifest = true
    }
}
if !hasManifest {
    return errors.New("jar has no META-INF/MANIFEST.MF")
}

Type guard

func isNotExist(err error) bool {
    return errors.Is(err, fs.ErrNotExist)
}

Try / catch

jar, err := expansionx.MakeJar(ctx, target, repo, version)
if err != nil && errors.Is(errors.Unwrap(errors.Unwrap(err)), fs.ErrNotExist) {
    os.RemoveAll(cacheDir) // re-extract fresh
    jar, err = expansionx.MakeJar(ctx, target, repo, version)
}

Prevention

When it happens

Trigger: extractJar succeeded but os.ReadFile(tmpDir+"/META-INF/MANIFEST.MF") returned an error: the manifest is missing from the JAR, the extraction produced a different directory layout, or tmpDir was removed between extract and read.

Common situations: A thin/generated JAR without a META-INF/MANIFEST.MF entry; extraction tooling or antivirus interfering with the temp dir; running MakeJar concurrently so another process cleaned tmpDir.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/9a7f05da4a2f4480. Report an issue: GitHub.

Appendix: source

Thrown at sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go:290

	// classpath jars should have relative path
	relClasspath := []string{}
	for _, path := range classpathJars {
		relPath, err := filepath.Rel(cacheDir, path)
		if err != nil {
			return "", fmt.Errorf("error in creating relative path: %w", err)
		}
		relClasspath = append(relClasspath, relPath)
	}

	tmpDir := filepath.Join(cacheDir, "tmpDir")

	if err := extractJar(mainJar, tmpDir); err != nil {
		return "", fmt.Errorf("error in extractJar(): %w", err)
	}

	manifest, err := os.ReadFile(tmpDir + "/META-INF/MANIFEST.MF")
	if err != nil {
		return "", fmt.Errorf("error readingf: %w", err)
	}

	// trim the empty lines present at the end of MANIFEST.MF file.
	manifestLines := strings.Split(string(manifest), "\n")
	manifestLines = manifestLines[:len(manifestLines)-2]

	classpathString := fmt.Sprintf("%sClass-Path: %s\n", strings.Join(manifestLines, "\n"), strings.Join(relClasspath, " "))
	if err = os.WriteFile(tmpDir+"/META-INF/MANIFEST.MF", []byte(classpathString), 0660); err != nil {
		return "", fmt.Errorf("error writing ta manifest file: %w", err)
	}

	path, err := os.Getwd()
	if err != nil {
		return "", fmt.Errorf("can't get current working directory: %w", err)
	}

	if err = os.Chdir(tmpDir); err != nil {
		return "", fmt.Errorf("can't change to temp directory %s for creating JAR: %w", tmpDir, err)

View on GitHub (pinned to 12126d8942)