{"record":{"id":"c97688fda75762e2","repo":"tsenart/vegeta","slug":"errnotargets","errorCode":"ErrNoTargets","errorMessage":"no targets to attack","messagePattern":"no targets to attack","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/targets.go","lineNumber":91,"sourceCode":"\t\tfor k := range t.Header {\n\t\t\tleft, right := t.Header[k], other.Header[k]\n\t\t\tif len(left) != len(right) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tfor i := range left {\n\t\t\t\tif left[i] != right[i] {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn true\n\t}\n}\n\nvar (\n\t// ErrNoTargets is returned when not enough Targets are available.\n\tErrNoTargets = errors.New(\"no targets to attack\")\n\t// ErrNilTarget is returned when the passed Target pointer is nil.\n\tErrNilTarget = errors.New(\"nil target\")\n\t// ErrNoMethod is returned by JSONTargeter when a parsed Target has\n\t// no method.\n\tErrNoMethod = errors.New(\"target: required method is missing\")\n\t// ErrNoURL is returned by JSONTargeter when a parsed Target has no\n\t// URL.\n\tErrNoURL = errors.New(\"target: required url is missing\")\n\t// TargetFormats contains the canonical list of the valid target\n\t// format identifiers.\n\tTargetFormats = []string{HTTPTargetFormat, JSONTargetFormat}\n)\n\nconst (\n\t// HTTPTargetFormat is the human readable identifier for the HTTP target format.\n\tHTTPTargetFormat = \"http\"\n\t// JSONTargetFormat is the human readable identifier for the JSON target format.\n\tJSONTargetFormat = \"json\"","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/tsenart/vegeta/blob/cf5811269046c672a604b1eb352204d30f16ae4a/lib/targets.go#L73-L109","documentation":"ErrNoTargets is returned by targeters (ReadAllTargets, HTTP/JSON targeters) when not enough Targets are available to run an attack. Vegeta refuses to attack an empty target set.","triggerScenarios":"ReadAllTargets hitting EOF before reading a single target; an empty/blank targets file; JSON target stream with no target objects; NewHTTPTargeter with a reader producing nothing.","commonSituations":"Empty targets.txt passed to `vegeta attack -targets`, wrong file path silently resolving to empty, line endings/format issues causing the parser to yield zero targets, or a JSON file containing only whitespace.","solutions":["Provide a non-empty targets file, e.g. lines like `GET http://localhost:8080/`.","Verify the path passed to -targets/ReadAllTargets points to the intended file and is readable.","Check target format flag matches the file content (http vs json)."],"exampleFix":"// before\ncat /dev/null | vegeta attack > results.bin  // empty targets\n// after\nprintf 'GET http://localhost:8080/\\n' > targets.txt\nvegeta attack -targets targets.txt > results.bin","handlingStrategy":"validation","validationCode":"fi, err := os.Stat(targetsPath)\nif err != nil || fi.Size() == 0 {\n    return errors.New(\"targets file missing or empty\")\n}","typeGuard":null,"tryCatchPattern":"if err := vegeta.ReadAllTargets(reader, format, &targets); err != nil {\n    if errors.Is(err, vegeta.ErrNoTargets) {\n        log.Fatal(\"no targets: check your -targets file and format flag\")\n    }\n    return err\n}","preventionTips":["Always sanity-check the targets file has content before attacking","Match -format (http/json) to the actual file contents","Count parsed targets and fail fast on zero"],"tags":["targets","validation","empty-input"],"backgroundTag":"empty-target-list","analyzedSha":"cf5811269046c672a604b1eb352204d30f16ae4a","analyzedAt":"2026-08-31T11:04:20.464Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}