{"record":{"id":"cc1e5acc9ba74c06","repo":"tsenart/vegeta","slug":"errnomethod","errorCode":"ErrNoMethod","errorMessage":"target: required method is missing","messagePattern":"target: required method is missing","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/targets.go","lineNumber":96,"sourceCode":"\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\"\n)\n\n// A Targeter decodes a Target or returns an error in case of failure.\n// Implementations must be safe for concurrent use.\ntype Targeter func(*Target) error","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/tsenart/vegeta/blob/cf5811269046c672a604b1eb352204d30f16ae4a/lib/targets.go#L78-L114","documentation":"ErrNoMethod is returned by the JSONTargeter when a decoded Target has no HTTP method set. A vegeta target must specify the request method to build a valid http.Request.","triggerScenarios":"A JSON targets entry without a \"method\" field (and no default method configured on the JSONTargeter) passed to vegeta attack with -format=json.","commonSituations":"Hand-written JSON target files missing the method key, an empty method string after decoding, or JSONTargeter created without a default method while targets omit it.","solutions":["Add a \"method\" field to each JSON target: {\"method\":\"GET\",\"url\":\"http://host/\"}.","Configure JSONTargeter with a non-empty default method so missing methods are filled in.","Validate target JSON against the expected schema before feeding it to vegeta."],"exampleFix":"// before\n{\"url\": \"http://localhost:8080/\"}\n// after\n{\"method\": \"GET\", \"url\": \"http://localhost:8080/\"}","handlingStrategy":"validation","validationCode":"var t vegeta.Target\nif err := json.Unmarshal(raw, &t); err != nil { return err }\nif t.Method == \"\" { return vegeta.ErrNoMethod }","typeGuard":null,"tryCatchPattern":"if err := vegeta.ReadAllTargets(f, vegeta.JSONTargetFormat, &targets); err != nil {\n    if errors.Is(err, vegeta.ErrNoMethod) {\n        log.Fatal(\"each JSON target needs a \\\"method\\\" field\")\n    }\n    return err\n}","preventionTips":["Include \"method\" in every JSON target object","Set JSONTargeter's default method when targets omit it","Lint target JSON files in CI before load tests"],"tags":["targets","json","validation"],"backgroundTag":"missing-required-field","analyzedSha":"cf5811269046c672a604b1eb352204d30f16ae4a","analyzedAt":"2026-08-31T11:04:20.464Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}