cilium/cilium · error
failed to create file %s: %w
Error message
failed to create file %s: %w
What it means
For each regular file entry, extractZip creates the destination file with os.OpenFile using the entry's stored permissions. Failure to create/open the destination file produces this wrapped error.
Source
Thrown at cilium-cli/features/summary.go:252
destPath := filepath.Join(destDir, cleanName)
if !strings.HasPrefix(destPath, filepath.Clean(destDir)+string(os.PathSeparator)) {
return fmt.Errorf("file path escapes destination directory: %s", destPath)
}
if file.FileInfo().IsDir() {
// Create directories
if err := os.MkdirAll(destPath, os.ModePerm); err != nil {
return fmt.Errorf("failed to create directory %s: %w", destPath, err)
}
continue
}
// Create directories
os.MkdirAll(filepath.Dir(destPath), os.ModePerm)
// Extract files
destFile, err := os.OpenFile(destPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, file.Mode())
if err != nil {
return fmt.Errorf("failed to create file %s: %w", destPath, err)
}
srcFile, err := file.Open()
if err != nil {
destFile.Close()
return fmt.Errorf("failed to open file in ZIP archive %s: %w", file.Name, err)
}
_, err = io.Copy(destFile, srcFile)
destFile.Close()
srcFile.Close()
if err != nil {
return fmt.Errorf("failed to extract file %s: %w", file.Name, err)
}
}
return nil
}
// nodesValues maps a node to valueView on GitHub (pinned to ac7b90affa)
Solutions
- Clean destDir and re-extract to remove stale conflicting entries
- Check free disk space and write permissions on destDir
- Retry with elevated permissions if the destination is protected
- Check for security software (SELinux/AppArmor) denying writes
Example fix
// before extractZip(tempFile, destDir) // after os.RemoveAll(destDir) os.MkdirAll(destDir, 0o755) extractZip(tempFile, destDir)
Defensive patterns
Strategy: validation
Validate before calling
if fi, err := os.Stat(destDir); err != nil || !fi.IsDir() {
return fmt.Errorf("destination %s must exist and be a directory", destDir)
} Try / catch
if err := extractZip(zipPath, destDir); err != nil {
var pathErr *fs.PathError
if errors.As(err, &pathErr) {
switch {
case errors.Is(pathErr.Err, fs.ErrPermission): // fix perms
case errors.Is(pathErr.Err, syscall.ENOSPC): // free disk space
}
}
return err
} Prevention
- Ensure sufficient free disk space
- Clean partial extraction state before retrying
- Confirm no security software blocks file creation
- Run with a user that owns destDir
When it happens
Trigger: os.OpenFile(destPath, O_WRONLY|O_CREATE|O_TRUNC, file.Mode()) fails: parent directory missing or unwritable, or the target exists as a directory/read-only file.
Common situations: Archive entries with modes like 0555 being re-extracted over existing files; disk full; antivirus or SELinux blocking writes; partial prior extraction left a directory where a file belongs.
Related errors
- Failed to open file %s for writing: %w
- could not create report dir %q: %w
- failed to create directory %s: %w
- failed to create temp file %s: %w
- failed to extract artifact %s: %w
AI-assisted analysis of cilium/cilium@ac7b90affa (2026-08-31).
Data as JSON: /api/errors/4bec191abc4411e9.
Report an issue: GitHub.