{"record":{"id":"92b3fcbecb2c7240","repo":"grafana/k6","slug":"couldn-t-parse-q-as-module-url-this-is-a-k6-bug","errorCode":null,"errorMessage":"couldn't parse %q as module url - this is a k6 bug, please report it (https://github.com/grafana/k6/issues)","messagePattern":"couldn't parse %q as module url - this is a k6 bug, please report it \\(https://github\\.com/grafana/k6/issues\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"js/modules/require_impl.go","lineNumber":136,"sourceCode":"\tvar u *url.URL\n\tswitch {\n\t// this works around windows URLs like file://C:/some/path\n\t// url.Parse will think of C: as hostname\n\tcase strings.HasPrefix(fileStr, \"file://\"):\n\t\tu = new(url.URL)\n\t\tu.Scheme = \"file\"\n\t\tu.Path, err = url.PathUnescape(strings.TrimPrefix(fileStr, \"file://\"))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\tcase strings.HasPrefix(fileStr, \"https://\"):\n\t\tvar err error\n\t\tu, err = url.Parse(fileStr)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"couldn't parse %q as module url - this is a k6 bug, \"+\n\t\t\t\"please report it (https://github.com/grafana/k6/issues)\", fileStr)\n\t}\n\treturn loader.Dir(u), nil\n}\n\n// ShouldWarnOnParentDirNotMatchingCurrentModuleParentDir is a helper function to figure out if the provided url\n// is the same folder that an import will be to.\n// It also checks if the modulesystem is locked which means we are past the first init context.\n// If false is returned means that we are not in the init context or the path is matching - so no warning should be done\n// If true, the returned path is the module path that it should be relative to - the one that is checked against.\nfunc (ms *ModuleSystem) ShouldWarnOnParentDirNotMatchingCurrentModuleParentDir(vu VU, parentModulePwd *url.URL,\n) (string, bool) {\n\tif ms.resolver.locked {\n\t\treturn \"\", false\n\t}\n\tnormalizePathToURL := func(path string) string {\n\t\tu, err := url.Parse(path)\n\t\tif err != nil {","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/js/modules/require_impl.go#L118-L154","documentation":"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.","triggerScenarios":"Thrown at js/modules/require_impl.go:136 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Report the issue at https://github.com/grafana/k6/issues with the script and module specifier that triggered it","As a workaround, import the module via a plain local path or https:// URL instead of whatever form produced the unparseable specifier"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}