{"record":{"id":"7128dba5cdd29209","repo":"grafana/k6","slug":"local-or-remote-path-required","errorCode":null,"errorMessage":"local or remote path required","messagePattern":"local or remote path required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/loader/loader.go","lineNumber":50,"sourceCode":"\t\t`local disk. Make sure that you've specified the right path to the file. If you're ` +\n\t\t`running k6 using the Docker image make sure you have mounted the ` +\n\t\t`local directory (-v /local/path/:/inside/docker/path) containing ` +\n\t\t`your script and modules so that they're accessible by k6 from ` +\n\t\t`inside of the container, see ` +\n\t\t`https://grafana.com/docs/k6/latest/using-k6/modules/#use-modules-with-docker.`\n)\n\ntype unresolvableURLError string\n\nfunc (u unresolvableURLError) Error() string {\n\t// TODO potentially add more things about what k6 supports if users report being confused.\n\treturn fmt.Sprintf(`The moduleSpecifier %q couldn't be recognised as something k6 supports.`, string(u))\n}\n\n// Resolve a relative path to an absolute one.\nfunc Resolve(pwd *url.URL, moduleSpecifier string) (*url.URL, error) {\n\tif moduleSpecifier == \"\" {\n\t\treturn nil, errors.New(\"local or remote path required\")\n\t}\n\n\tif moduleSpecifier[0] == '.' || moduleSpecifier[0] == '/' || filepath.IsAbs(moduleSpecifier) {\n\t\treturn resolveFilePath(pwd, moduleSpecifier)\n\t}\n\n\tif strings.Contains(moduleSpecifier, \"://\") {\n\t\tu, err := url.Parse(moduleSpecifier)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif u.Scheme != \"file\" && u.Scheme != \"https\" {\n\t\t\treturn nil,\n\t\t\t\tfmt.Errorf(\"only supported schemes for imports are file and https, %s has `%s`\",\n\t\t\t\t\tmoduleSpecifier, u.Scheme)\n\t\t}\n\t\tif u.Scheme == \"file\" && pwd.Scheme == \"https\" {\n\t\t\treturn nil, fmt.Errorf(\"origin (%s) not allowed to load local file: %s\", pwd, moduleSpecifier)","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/loader/loader.go#L32-L68","documentation":"loader.Resolve maps a module specifier to a filesystem path or remote https URL. It refuses an empty specifier up front with 'local or remote path required' because there is nothing to resolve. This is the entry point used for resolving imports and open() file paths, so the error means an empty string was passed where a path was expected.","triggerScenarios":"Calling open('') in a k6 script; import of a specifier that a template string or variable built to be empty; programmatic use of loader.Resolve(pwd, \"\") in Go.","commonSituations":"A filename variable that is undefined/empty (e.g., from __ENV or a data-driven loop) is passed to open(); path templates like `${base}/${file}` collapsing when all parts are empty.","solutions":["Validate the specifier is non-empty before calling open()/importing","Fix the variable that produced the empty string (check __ENV values, loop data, defaulting logic)","Pass a literal relative or absolute path, or an https URL"],"exampleFix":"// before\nconst data = open(__ENV.DATA_FILE); // DATA_FILE unset -> \"\"\n// after\nconst file = __ENV.DATA_FILE;\nif (!file) throw new Error('DATA_FILE must point to a data file');\nconst data = open(file);","handlingStrategy":"validation","validationCode":"// k6 script (JS)\nfunction requirePath(p, name) {\n  if (typeof p !== 'string' || p.trim() === '') {\n    throw new Error(`${name} must be a non-empty file path`);\n  }\n  return p;\n}\nconst data = open(requirePath(__ENV.DATA_FILE, 'DATA_FILE'));","typeGuard":"function isNonEmptySpecifier(s) {\n  return typeof s === 'string' && s.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Never pass __ENV values straight into open() — default and validate them first","Fail fast on empty computed paths before the loader sees them","Log the resolved specifier in debug output so empty strings are obvious"],"tags":["modules","filesystem","import","path-resolution","k6"],"backgroundTag":"invalid-module-specifier","analyzedSha":"8d06114777191d21ef885d05c5f8aa9e1ed838ae","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}