apache/beam · error

error accesing path

Error message

error accesing path %s: %w

What it means

While walking the source tree inside packJar, filepath.Walk invoked the callback with a non-nil err for a path — the directory entry itself could not be read (open/readdir/lstat failure). The code wraps it with the offending path so you know which node of the tree was inaccessible.

Solutions

  1. Fix permissions on the source tree so the packing process can read all files/dirs (chmod -R u+rX tmpDir).
  2. Remove dangling symlinks or unreadable entries from the extraction directory.
  3. Recreate the tree cleanly: delete tmpDir, re-run extractJar, then pack.
  4. Check no concurrent process is mutating the source directory during packing.
Defensive patterns

Strategy: try-catch

Validate before calling

err := filepath.Walk(source, func(p string, fi os.FileInfo, err error) error {
    if err != nil { return err } // surface early
    return nil
})

Try / catch

err = filepath.Walk(source, func(path string, fi os.FileInfo, err error) error {
    if err != nil {
        var pe *fs.PathError
        if errors.As(err, &pe) && (errors.Is(pe.Err, fs.ErrPermission) || errors.Is(pe.Err, fs.ErrNotExist)) {
            return fmt.Errorf("error accesing path %s: %w", path, err) // log & skip vs fail per policy
        }
        return err
    }
    return packEntry(path, fi)
})

Prevention

When it happens

Trigger: filepath.Walk(source, ...) hits a path it cannot access: unreadable subdirectory, dangling symlink whose lstat fails, file deleted between listing and visiting, or permission errors on nested dirs (EACCES, ENOENT).

Common situations: JAR contents extracted with restrictive modes (dirs created 0700 by extractJar) and packing runs as a different user; a symlink in tmpDir pointing outside to a deleted target; file removed by a concurrent cleanup while walking.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


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

Appendix: source

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

	}
	defer jar.Close()

	jarFile := zip.NewWriter(jar)
	defer jarFile.Close()

	fileInfo, err := os.Stat(source)
	if err != nil {
		return fmt.Errorf("source path %s doesn't exist: %w", source, err)
	}

	var sourceDir string
	if fileInfo.IsDir() {
		sourceDir = filepath.Base(source)
	}

	err = filepath.Walk(source, func(path string, fileInfo os.FileInfo, err error) error {
		if err != nil {
			return fmt.Errorf("error accesing path %s: %w", path, err)
		}
		fileHeader, err := zip.FileInfoHeader(fileInfo)
		if err != nil {
			return fmt.Errorf("error getting FileInfoHeader: %w", err)
		}

		if sourceDir != "" {
			fileHeader.Name = filepath.Join(sourceDir, strings.TrimPrefix(path, source))
		}

		if fileInfo.IsDir() {
			fileHeader.Name += "/"
		} else {
			fileHeader.Method = zip.Deflate
		}

		writer, err := jarFile.CreateHeader(fileHeader)
		if err != nil {

View on GitHub (pinned to 12126d8942)