grafana/k6 · error

open() failed, unable to verify if

Error message

open() failed, unable to verify if %q exists; reason: %w

What it means

Raised in openImpl when fsext.Exists fails while checking whether the (entrypoint-relative, file://-stripped) path exists on the 'file' filesystem. This is an I/O-level failure of the existence check itself, distinct from a plain missing-file error.

Solutions

  1. Inspect the wrapped error for the filesystem-level cause
  2. Verify the path is correct relative to the init-time working directory
  3. Check that the file is included in the archive or fsext filesystem being used
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at internal/js/modules/k6/experimental/fs/module.go:125 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/3718a36027f7b7ea. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/experimental/fs/module.go:125

	path = strings.TrimPrefix(path, "file://")

	// We resolve the path relative to the entrypoint script, as opposed to
	// the current working directory (the k6 command is called from).
	//
	// This is done on purpose, although it diverges in some respect with
	// 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
	}

View on GitHub (pinned to 01ffac6f24)