{"record":{"id":"3718a36027f7b7ea","repo":"grafana/k6","slug":"open-failed-unable-to-verify-if-q-exists-reas","errorCode":null,"errorMessage":"open() failed, unable to verify if %q exists; reason: %w","messagePattern":"open\\(\\) failed, unable to verify if %q exists; reason: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/experimental/fs/module.go","lineNumber":125,"sourceCode":"\tpath = strings.TrimPrefix(path, \"file://\")\n\n\t// We resolve the path relative to the entrypoint script, as opposed to\n\t// the current working directory (the k6 command is called from).\n\t//\n\t// This is done on purpose, although it diverges in some respect with\n\t// how files are handled in different k6 contexts, so that we cater to\n\t// and intuitive user experience.\n\t//\n\t// See #2781 and #2674.\n\tpath = fsext.Abs(initEnv.CWD.Path, path)\n\n\tfs, ok := initEnv.FileSystems[\"file\"]\n\tif !ok {\n\t\treturn nil, errors.New(\"open() failed; reason: unable to access the file system\")\n\t}\n\n\tif exists, err := fsext.Exists(fs, path); err != nil {\n\t\treturn nil, fmt.Errorf(\"open() failed, unable to verify if %q exists; reason: %w\", path, err)\n\t} else if !exists {\n\t\treturn nil, newFsError(NotFoundError, fmt.Sprintf(\"no such file or directory %q\", path))\n\t}\n\n\tif isDir, err := fsext.IsDir(fs, path); err != nil {\n\t\treturn nil, fmt.Errorf(\"open() failed, unable to verify if %q is a directory; reason: %w\", path, err)\n\t} else if isDir {\n\t\treturn nil, newFsError(\n\t\t\tInvalidResourceError,\n\t\t\tfmt.Sprintf(\"cannot open %q: opening a directory is not supported\", path),\n\t\t)\n\t}\n\n\tdata, err := mi.cache.open(path, fs)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/experimental/fs/module.go#L107-L143","documentation":"Thrown by the experimental fs module's open() in the init context. After resolving the path against the init CWD, k6 calls fsext.Exists to verify it; if that check itself errors (not 'file missing' - a missing file produces a NotFoundError 'no such file or directory'), the error is wrapped as 'open() failed, unable to verify if %q exists' (internal/js/modules/k6/experimental/fs/module.go:125). The failure is in the underlying filesystem's Stat, and the resolved path is included in the message.","triggerScenarios":"fs.open(path) where Stat on the resolved path fails: permission denied on the file or a parent directory, a corrupted entry inside a k6 archive, or an fsext backend error.","commonSituations":"Restrictive permissions in hardened containers/CI runners; manually unpacked and repacked k6 archives; case-sensitivity mistakes that surface as stat failures on case-sensitive filesystems.","solutions":["Check the exact path printed in the message - spelling and case - relative to the script's directory","Verify read permission on the file and every parent directory (chmod/chcon as needed)","If running from an archive, rebuild it from the original script tree instead of editing it by hand"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const f = open(path);\n} catch (e) {\n  if (/unable to verify if .* exists/.test(e.message)) {\n    throw new Error(`stat failed for ${path}: check permissions and archive integrity`);\n  }\n  throw e;\n}","preventionTips":["Use paths relative to the script file, not the shell CWD","Verify read permissions on the file and parent dirs in CI images","Rebuild archives from sources instead of editing them"],"tags":["fs","k6","filesystem","permissions","experimental"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}