grafana/k6 · error
open() failed, unable to verify if
Error message
open() failed, unable to verify if %q is a directory; reason: %w
What it means
Raised in openImpl when the stat-based check for directory-ness fails with an error (not when the path is merely absent). The wrapped error gives the I/O reason the isDirectory check could not be performed.
Solutions
- Inspect the wrapped stat error for the underlying cause
- Verify filesystem permissions and that the path is accessible
- Ensure the file exists and is a regular file, not a special filesystem object
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at internal/js/modules/k6/experimental/fs/module.go:131 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/5430be752ed34804.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/experimental/fs/module.go:131
// how files are handled in different k6 contexts, so that we cater to
// and intuitive user experience.
//
// See #2781 and #2674.
path = fsext.Abs(initEnv.CWD.Path, path)
fs, ok := initEnv.FileSystems["file"]
if !ok {
return nil, errors.New("open() failed; reason: unable to access the file system")
}
if exists, err := fsext.Exists(fs, path); err != nil {
return nil, fmt.Errorf("open() failed, unable to verify if %q exists; reason: %w", path, err)
} else if !exists {
return nil, newFsError(NotFoundError, fmt.Sprintf("no such file or directory %q", path))
}
if isDir, err := fsext.IsDir(fs, path); err != nil {
return nil, fmt.Errorf("open() failed, unable to verify if %q is a directory; reason: %w", path, err)
} else if isDir {
return nil, newFsError(
InvalidResourceError,
fmt.Sprintf("cannot open %q: opening a directory is not supported", path),
)
}
data, err := mi.cache.open(path, fs)
if err != nil {
return nil, err
}
file := &File{
Path: path,
ReadSeekStater: &file{
path: path,
data: data,
},View on GitHub (pinned to 01ffac6f24)