{"record":{"id":"c4d405cee3fc8992","repo":"tsenart/vegeta","slug":"errnourl","errorCode":"ErrNoURL","errorMessage":"target: required url is missing","messagePattern":"target: required url is missing","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/targets.go","lineNumber":99,"sourceCode":"\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\n\n// Decode is a convenience method that calls the underlying Targeter function.\nfunc (tr Targeter) Decode(t *Target) error {","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/tsenart/vegeta/blob/cf5811269046c672a604b1eb352204d30f16ae4a/lib/targets.go#L81-L117","documentation":"ErrNoURL is returned by the JSONTargeter when a decoded Target has no URL set. Without a URL vegeta cannot construct the attack request.","triggerScenarios":"A JSON targets entry without a \"url\" field (and no default URL configured on the JSONTargeter), e.g. `-format=json` with malformed target objects.","commonSituations":"Typos in the JSON key (\"uri\", \"endpoint\"), forgetting to combine a path with the default URL, or template targets whose URL evaluates to an empty string.","solutions":["Add a \"url\" field to each JSON target: {\"method\":\"GET\",\"url\":\"http://host/path\"}.","Configure JSONTargeter with a default URL/base so targets only carry paths.","Validate the JSON targets file with jq or a schema check before running the attack."],"exampleFix":"// before\n{\"method\": \"GET\"}\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.URL == \"\" { return vegeta.ErrNoURL }","typeGuard":null,"tryCatchPattern":"if err := vegeta.ReadAllTargets(f, vegeta.JSONTargetFormat, &targets); err != nil {\n    if errors.Is(err, vegeta.ErrNoURL) {\n        log.Fatal(\"each JSON target needs a \\\"url\\\" field\")\n    }\n    return err\n}","preventionTips":["Include \"url\" in every JSON target object","Watch for key typos (uri/endpoint vs url)","Combine default base URL with per-target paths instead of leaving url empty"],"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"}