{"record":{"id":"5430be752ed34804","repo":"grafana/k6","slug":"open-failed-unable-to-verify-if-q-is-a-directo","errorCode":null,"errorMessage":"open() failed, unable to verify if %q is a directory; reason: %w","messagePattern":"open\\(\\) failed, unable to verify if %q is a directory; reason: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/experimental/fs/module.go","lineNumber":131,"sourceCode":"\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\n\tfile := &File{\n\t\tPath: path,\n\t\tReadSeekStater: &file{\n\t\t\tpath: path,\n\t\t\tdata: data,\n\t\t},","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/experimental/fs/module.go#L113-L149","documentation":"Raised in openImpl when the stat-based check for directory-ness fails with an error (not when the path is merely absent). The wrapped error gives the I/O reason the isDirectory check could not be performed.","triggerScenarios":"Thrown at internal/js/modules/k6/experimental/fs/module.go:131 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped stat error for the underlying cause","Verify filesystem permissions and that the path is accessible","Ensure the file exists and is a regular file, not a special filesystem object"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}