grafana/k6 · error

couldn't parse %q as module url - this is a k6 bug, please r

Error message

couldn't parse %q as module url - this is a k6 bug, please report it (https://github.com/grafana/k6/issues)

What it means

CurrentlyRequiredModule hit the default branch of its URL classification: the module specifier is neither file:// nor https:// prefixed after going through the resolver, so it cannot be turned into a URL. The message itself states this indicates an internal k6 bug — an invariant about specifier schemes was violated, not a user script error.

Source

Thrown at js/modules/require_impl.go:136

	var u *url.URL
	switch {
	// this works around windows URLs like file://C:/some/path
	// url.Parse will think of C: as hostname
	case strings.HasPrefix(fileStr, "file://"):
		u = new(url.URL)
		u.Scheme = "file"
		u.Path, err = url.PathUnescape(strings.TrimPrefix(fileStr, "file://"))
		if err != nil {
			return nil, err
		}
	case strings.HasPrefix(fileStr, "https://"):
		var err error
		u, err = url.Parse(fileStr)
		if err != nil {
			return nil, err
		}
	default:
		return nil, fmt.Errorf("couldn't parse %q as module url - this is a k6 bug, "+
			"please report it (https://github.com/grafana/k6/issues)", fileStr)
	}
	return loader.Dir(u), nil
}

// ShouldWarnOnParentDirNotMatchingCurrentModuleParentDir is a helper function to figure out if the provided url
// is the same folder that an import will be to.
// It also checks if the modulesystem is locked which means we are past the first init context.
// If false is returned means that we are not in the init context or the path is matching - so no warning should be done
// If true, the returned path is the module path that it should be relative to - the one that is checked against.
func (ms *ModuleSystem) ShouldWarnOnParentDirNotMatchingCurrentModuleParentDir(vu VU, parentModulePwd *url.URL,
) (string, bool) {
	if ms.resolver.locked {
		return "", false
	}
	normalizePathToURL := func(path string) string {
		u, err := url.Parse(path)
		if err != nil {

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Report the issue at https://github.com/grafana/k6/issues with the script and module specifier that triggered it
  2. As a workaround, import the module via a plain local path or https:// URL instead of whatever form produced the unparseable specifier
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at js/modules/require_impl.go:136 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/92b3fcbecb2c7240. Report an issue: GitHub.