{"record":{"id":"e7879b2584a89eed","repo":"tsenart/vegeta","slug":"bad-target-s","errorCode":null,"errorMessage":"bad target: %s","messagePattern":"bad target: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/targets.go","lineNumber":293,"sourceCode":"\t\t\tif !sc.Scan() {\n\t\t\t\treturn ErrNoTargets\n\t\t\t}\n\t\t\tline = strings.TrimSpace(sc.Text())\n\n\t\t\tif len(line) != 0 && line[0] != '#' {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\ttgt.Body = body\n\t\ttgt.Header = http.Header{}\n\t\tfor k, vs := range hdr {\n\t\t\ttgt.Header[k] = vs\n\t\t}\n\n\t\ttokens := strings.SplitN(line, \" \", 2)\n\t\tif len(tokens) < 2 {\n\t\t\treturn fmt.Errorf(\"bad target: %s\", line)\n\t\t}\n\t\tif !startsWithHTTPMethod(line) {\n\t\t\treturn fmt.Errorf(\"bad method: %s\", tokens[0])\n\t\t}\n\t\ttgt.Method = tokens[0]\n\t\tif _, err = url.ParseRequestURI(tokens[1]); err != nil {\n\t\t\treturn fmt.Errorf(\"bad URL: %s, %w\", tokens[1], err)\n\t\t}\n\t\ttgt.URL = tokens[1]\n\t\tline = strings.TrimSpace(sc.Peek())\n\t\tif line == \"\" || startsWithHTTPMethod(line) {\n\t\t\treturn nil\n\t\t}\n\t\tfor sc.Scan() {\n\t\t\tif line = strings.TrimSpace(sc.Text()); line == \"\" {\n\t\t\t\tbreak\n\t\t\t} else if strings.HasPrefix(line, \"#\") {\n\t\t\t\tcontinue","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/tsenart/vegeta/blob/cf5811269046c672a604b1eb352204d30f16ae4a/lib/targets.go#L275-L311","documentation":"Returned by vegeta's targets parser (NewIntegerTargets/encoder decoding) when a target definition line does not contain a METHOD and URL separated by a space. The line is split on the first space; fewer than two tokens means no URL was supplied.","triggerScenarios":"Parsing a targets file/line that lacks a URL, e.g. a line containing only \"GET\", an empty-ish line with stray whitespace, or a line that is a comment/comment-like text without '#'.","commonSituations":"Hand-written targets.txt with missing URLs, CRLF line endings mangling lines, accidentally pasting headers before the first request line, or using a description line without a leading '#'.","solutions":["Ensure every target line has the form \"METHOD URL\", e.g. \"GET http://localhost:8080/\".","Prefix any comment lines with '#' so they are skipped.","Strip trailing carriage returns (dos2unix) or ensure the URL isn't on a separate line from the method.","Check the exact offending line printed in the error and fix it in the targets file."],"exampleFix":"// before (targets.txt)\nGET\n// after\nGET http://localhost:8080/","handlingStrategy":"validation","validationCode":"func validTargetLine(line string) bool {\n    parts := strings.SplitN(line, \" \", 2)\n    return len(parts) == 2 && strings.TrimSpace(parts[1]) != \"\" &&\n        !strings.HasPrefix(line, \"#\")\n}","typeGuard":null,"tryCatchPattern":"tgt, err := vegeta.NewTargetsFromFile(path)\nif err != nil && strings.HasPrefix(err.Error(), \"bad target:\") {\n    return fmt.Errorf(\"targets file %s: every line needs 'METHOD URL': %w\", path, err)\n}","preventionTips":["Every non-comment line must be 'METHOD URL'.","Prefix comments with '#'.","Run dos2unix on targets files authored on Windows.","Validate the targets file in CI before running attacks."],"tags":["go","targets","configuration"],"backgroundTag":"invalid-target-format","analyzedSha":"cf5811269046c672a604b1eb352204d30f16ae4a","analyzedAt":"2026-08-31T11:04:20.464Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}