{"record":{"id":"3a3adde83f1884d2","repo":"tsenart/vegeta","slug":"bad-method-s","errorCode":null,"errorMessage":"bad method: %s","messagePattern":"bad method: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/targets.go","lineNumber":296,"sourceCode":"\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\n\t\t\t} else if strings.HasPrefix(line, \"@\") {\n\t\t\t\tif tgt.Body, err = os.ReadFile(line[1:]); err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"bad body: %w\", err)","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/tsenart/vegeta/blob/cf5811269046c672a604b1eb352204d30f16ae4a/lib/targets.go#L278-L314","documentation":"Returned when a target line starts with a token that is not a recognized HTTP method. The line parsed into METHOD URL but startsWithHTTPMethod rejects the first token, so vegeta wraps it as \"bad method\".","triggerScenarios":"A targets line whose first token is not one of GET/POST/PUT/DELETE/PATCH/HEAD/OPTIONS etc., e.g. \"get\" capitalized differently if unsupported, or a typo like \"GETT http://...\" or \"get-http://x\".","commonSituations":"Typos in targets files, custom/unsupported verbs (e.g. PROPFIND if not in the recognized list), template placeholders left unfilled like \"{{METHOD}} http://...\".","solutions":["Use a standard uppercase HTTP method as the first token: GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS.","Fix typos in the method name on the offending line.","Replace placeholder variables with a real method before passing the targets file to vegeta.","If you need a custom method, check startsWithHTTPMethod's supported list and upgrade vegeta or preprocess the file."],"exampleFix":"// before\ncurl http://localhost:8080/\n// after\nGET http://localhost:8080/","handlingStrategy":"validation","validationCode":"var httpMethods = []string{\"GET\",\"HEAD\",\"POST\",\"PUT\",\"PATCH\",\"DELETE\",\"CONNECT\",\"OPTIONS\",\"TRACE\"}\nfunc hasHTTPMethod(line string) bool {\n    m := strings.ToUpper(strings.Fields(line)[0])\n    return slices.Contains(httpMethods, m)\n}","typeGuard":null,"tryCatchPattern":"if _, err := vegeta.NewTargets(r); err != nil {\n    var bad *fmt.wrapError\n    if strings.Contains(err.Error(), \"bad method:\") {\n        return fmt.Errorf(\"use a standard uppercase HTTP method: %w\", err)\n    }\n    return err\n}","preventionTips":["Use uppercase standard HTTP methods as the first token.","Lint targets files against a known method list.","Avoid custom verbs unless your vegeta version supports them.","Replace template placeholders before parsing."],"tags":["go","targets","http-method"],"backgroundTag":"invalid-target-format","analyzedSha":"cf5811269046c672a604b1eb352204d30f16ae4a","analyzedAt":"2026-08-31T11:04:20.464Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}