grafana/k6 · error

only supported schemes for imports are file and https, %s ha

Error message

only supported schemes for imports are file and https, %s has `%s`

What it means

A validation guard in Resolve. k6 only loads modules via file:// or https:// URLs; it fires when an import specifier containing '://' uses any other scheme (e.g. http://, ws://). The at-fault inputs are the module specifier and its unsupported scheme.

Source

Thrown at internal/loader/loader.go:64

// Resolve a relative path to an absolute one.
func Resolve(pwd *url.URL, moduleSpecifier string) (*url.URL, error) {
	if moduleSpecifier == "" {
		return nil, errors.New("local or remote path required")
	}

	if moduleSpecifier[0] == '.' || moduleSpecifier[0] == '/' || filepath.IsAbs(moduleSpecifier) {
		return resolveFilePath(pwd, moduleSpecifier)
	}

	if strings.Contains(moduleSpecifier, "://") {
		u, err := url.Parse(moduleSpecifier)
		if err != nil {
			return nil, err
		}
		if u.Scheme != "file" && u.Scheme != "https" {
			return nil,
				fmt.Errorf("only supported schemes for imports are file and https, %s has `%s`",
					moduleSpecifier, u.Scheme)
		}
		if u.Scheme == "file" && pwd.Scheme == "https" {
			return nil, fmt.Errorf("origin (%s) not allowed to load local file: %s", pwd, moduleSpecifier)
		}
		return u, err
	}

	if strings.HasPrefix(moduleSpecifier, "cdnjs.com") {
		return nil, fmt.Errorf("cdnjs.com 'special' urls are no longer supported - please use real ones. " +
			"You can get yours by going to cdnjs and copy-pasting the full url to the actual JavaScript file")
	}
	if strings.HasPrefix(moduleSpecifier, "github.com") {
		return nil, fmt.Errorf("github.com 'special' urls are no longer supported - please use real ones. " +
			"You can get yours by going to github and copy-pasting the full url to the actual raw JavaScript file")
	}
	return nil, unresolvableURLError(moduleSpecifier)
}

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Use https:// for remote modules instead of http://
  2. Use file:// or a relative/absolute path for local modules
  3. Import from a supported CDN over https (e.g. jslib.k6.io)
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/loader/loader.go:64 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/fd8169cff0a25bff. Report an issue: GitHub.