{"record":{"id":"07e454588ff8cc8a","repo":"tsenart/vegeta","slug":"error-opening-s-s","errorCode":null,"errorMessage":"error opening %s: %s","messagePattern":"error opening (.+?): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"attack.go","lineNumber":139,"sourceCode":"\n\tif len(opts.resolvers) > 0 {\n\t\tres, err := resolver.NewResolver(opts.resolvers)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tnet.DefaultResolver = res\n\t}\n\n\tnet.DefaultResolver.PreferGo = true\n\n\tfiles := map[string]io.Reader{}\n\tfor _, filename := range []string{opts.targetsf, opts.bodyf} {\n\t\tif filename == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tf, err := file(filename, false)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error opening %s: %s\", filename, err)\n\t\t}\n\t\tdefer f.Close()\n\t\tfiles[filename] = f\n\t}\n\n\tvar body []byte\n\tif bodyf, ok := files[opts.bodyf]; ok {\n\t\tif body, err = io.ReadAll(bodyf); err != nil {\n\t\t\treturn fmt.Errorf(\"error reading %s: %s\", opts.bodyf, err)\n\t\t}\n\t}\n\n\tvar (\n\t\ttr       vegeta.Targeter\n\t\tsrc      = files[opts.targetsf]\n\t\thdr      = opts.headers.Header\n\t\tproxyHdr = opts.proxyHeaders.Header\n\t)","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/tsenart/vegeta/blob/cf5811269046c672a604b1eb352204d30f16ae4a/attack.go#L121-L157","documentation":"attack() opens the targets file and optional body file before launching the attack; if `file()` (os.Open-style) fails, the error is wrapped with the offending filename. This almost always means the path does not exist or is not readable.","triggerScenarios":"Passing `-targets=<path>` or `-body=<path>` pointing to a nonexistent file, a directory, or a file the current user cannot read.","commonSituations":"Typo in path; running vegeta from a different working directory than assumed; relative path in cron/CI with different cwd; missing permissions in containerized environments.","solutions":["Verify the file exists at the given path (`ls <path>`) and fix the path/typo.","Run vegeta from the directory you expect, or use absolute paths for -targets/-body.","Check file permissions (readable by the user running vegeta); if the path is a directory, point to a regular file."],"exampleFix":"// before\nvegeta attack -targets=./tragets.txt\n// after\nvegeta attack -targets=./targets.txt","handlingStrategy":"validation","validationCode":"for _, f := range []string{targetsPath, bodyPath} {\n    if f == \"\" { continue }\n    if st, err := os.Stat(f); err != nil || st.IsDir() {\n        return fmt.Errorf(\"input %q is not a readable file\", f)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use absolute paths for -targets and -body in scripts and CI.","Check file existence/permissions with os.Stat before invoking vegeta.","Run vegeta from a known working directory (set cwd explicitly in CI)."],"tags":["cli","filesystem","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"cf5811269046c672a604b1eb352204d30f16ae4a","analyzedAt":"2026-08-31T11:04:20.464Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}