{"record":{"id":"9c23a555a59fde22","repo":"tsenart/vegeta","slug":"errniltarget","errorCode":"ErrNilTarget","errorMessage":"nil target","messagePattern":"nil target","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/targets.go","lineNumber":93,"sourceCode":"\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\"\n)\n","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/tsenart/vegeta/blob/cf5811269046c672a604b1eb352204d30f16ae4a/lib/targets.go#L75-L111","documentation":"ErrNilTarget is returned when a Targeter yields a nil *Target pointer. The attacker requires a fully allocated Target to issue a request, so a nil pointer is rejected defensively.","triggerScenarios":"A custom Targeter func writing nothing into the *Target out-parameter (or returning a nil target) while returning nil error; JSON/HTTP targeters encountering nil entries in their pipelines.","commonSituations":"Hand-written Targeter wrappers that forget to populate the out param, decoding into a nil pointer, or test fixtures with missing entries.","solutions":["Fix the custom Targeter to allocate and populate the target: *tgt = &vegeta.Target{...} before returning nil.","Return a descriptive error from your Targeter instead of nil target + nil error.","Check for nil target inside your targeter and skip/log such entries."],"exampleFix":"// before\nfunc(tgt *vegeta.Target) error { return nil }\n// after\nfunc(tgt *vegeta.Target) error {\n    if tgt == nil { return errors.New(\"nil target out-param\") }\n    *tgt = vegeta.Target{Method: \"GET\", URL: \"http://localhost/\"}\n    return nil\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func validTarget(t *vegeta.Target) bool {\n    return t != nil && t.Method != \"\" && t.URL != \"\"\n}","tryCatchPattern":"if t, err := targeter(&tr); err != nil {\n    return err\n} else if t == nil {\n    return vegeta.ErrNilTarget\n}","preventionTips":["In custom Targeters, always allocate the out Target before returning nil","Never return (nil, nil) from a Targeter","Unit-test custom targeters against the nil-target case"],"tags":["targets","nil-pointer","targeter"],"backgroundTag":"nil-target-returned","analyzedSha":"cf5811269046c672a604b1eb352204d30f16ae4a","analyzedAt":"2026-08-31T11:04:20.464Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}