dagger/dagger · error
failed to list xattrs on %s: %w
Error message
failed to list xattrs on %s: %w
What it means
copyXattrs failed while calling Listxattr on the source path to enumerate extended attributes before copying them to the destination. The library treats ENOTSUP/ENODATA as benign (returns nil), so this error only fires for genuinely unexpected failures (EACCES, EIO, stale file handle, etc.). It wraps the underlying syscall error with the source path.
Source
Thrown at util/layercopy/dest_linux.go:567
}
if modeOverride != nil {
if err := os.Chmod(dstPath, *modeOverride); err != nil {
return err
}
}
return nil
}
func copyXattrs(dstPath, srcPath string, _ bool, xattrErrorHandler XAttrErrorHandler) error {
xattrs, err := sysx.LListxattr(srcPath)
if err != nil {
if errors.Is(err, unix.ENOTSUP) || errors.Is(err, unix.ENODATA) {
return nil
}
if xattrErrorHandler != nil {
return xattrErrorHandler(dstPath, srcPath, "", err)
}
return fmt.Errorf("failed to list xattrs on %s: %w", srcPath, err)
}
for _, xattr := range xattrs {
if xattr == "trusted.overlay.opaque" || xattr == "user.overlay.opaque" {
continue
}
val, err := sysx.LGetxattr(srcPath, xattr)
if err != nil {
if errors.Is(err, unix.ENODATA) {
continue
}
if xattrErrorHandler != nil {
if err := xattrErrorHandler(dstPath, srcPath, xattr, err); err != nil {
return err
}
continue
}
return fmt.Errorf("failed to get xattr %q on %s: %w", xattr, srcPath, err)
}View on GitHub (pinned to 82ba2681db)
Solutions
- Check the wrapped %w cause for the real errno (EACCES/EIO/ESTALE) and fix filesystem access or permissions on srcPath.
- Ensure the source filesystem is stable and not being mutated during the copy.
- Set a custom xattrErrorHandler to downgrade/list xattr failures as warnings instead of failing the copy.
- If the filesystem does not support xattrs at all, mount it with xattr support (e.g. overlay 'userxattr' or fstab user_xattr).
Example fix
// before: copy fails on xattr list error
// after: supply a tolerant handler
copyMetadata(src, dst, WithXattrErrorHandler(func(dst, src, xattr string, err error) error {
log.Warnf("skipping xattrs on %s: %v", src, err)
return nil
})) Defensive patterns
Strategy: try-catch
Validate before calling
// ensure source is readable & fs supports xattrs
if _, err := os.Stat(srcPath); err != nil { return err }
if _, err := sysx.LListxattr(srcPath); err != nil && !errors.Is(err, unix.ENOTSUP) && !errors.Is(err, unix.ENODATA) { return err } Try / catch
err := copyMetadata(...)
var xerr error
if errors.As(err, &xerr) && strings.Contains(err.Error(), "failed to list xattrs") {
log.Warn("xattr listing unavailable, continuing without xattrs", "cause", err)
} else if err != nil {
return err
} Prevention
- Install an xattrErrorHandler for tolerant copies
- Verify xattr support on the source filesystem before copying
- Avoid mutating the source layer mid-copy
When it happens
Trigger: copyXattrs (invoked via copyMetadata during layer copy) calls Listxattr(srcPath) on a file in the source layer; the syscall returns an error other than ENOTSUP or ENODATA and no xattrErrorHandler short-circuits it.
Common situations: Reading layers from a damaged or concurrently-mutated filesystem; files on network/overlay mounts that reject xattr listing mid-copy; permission-restricted sources; NFS with expired file handles.
Related errors
- failed to get xattr %q on %s: %w
- remount container: %w
- failed to read %s: %w
- failed to read %s: %w
- failed to read %s: %w
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/c98231eddd09c26e.
Report an issue: GitHub.