tsenart/vegeta · error
ErrNoMethod
ErrNoMethod
Error message
target: required method is missing
What it means
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.
Source
Thrown at lib/targets.go:96
for i := range left {
if left[i] != right[i] {
return false
}
}
}
return true
}
}
var (
// ErrNoTargets is returned when not enough Targets are available.
ErrNoTargets = errors.New("no targets to attack")
// ErrNilTarget is returned when the passed Target pointer is nil.
ErrNilTarget = errors.New("nil target")
// ErrNoMethod is returned by JSONTargeter when a parsed Target has
// no method.
ErrNoMethod = errors.New("target: required method is missing")
// ErrNoURL is returned by JSONTargeter when a parsed Target has no
// URL.
ErrNoURL = errors.New("target: required url is missing")
// TargetFormats contains the canonical list of the valid target
// format identifiers.
TargetFormats = []string{HTTPTargetFormat, JSONTargetFormat}
)
const (
// HTTPTargetFormat is the human readable identifier for the HTTP target format.
HTTPTargetFormat = "http"
// JSONTargetFormat is the human readable identifier for the JSON target format.
JSONTargetFormat = "json"
)
// A Targeter decodes a Target or returns an error in case of failure.
// Implementations must be safe for concurrent use.
type Targeter func(*Target) errorView on GitHub (pinned to cf58112690)
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.
Example fix
// before
{"url": "http://localhost:8080/"}
// after
{"method": "GET", "url": "http://localhost:8080/"} Defensive patterns
Strategy: validation
Validate before calling
var t vegeta.Target
if err := json.Unmarshal(raw, &t); err != nil { return err }
if t.Method == "" { return vegeta.ErrNoMethod } Try / catch
if err := vegeta.ReadAllTargets(f, vegeta.JSONTargetFormat, &targets); err != nil {
if errors.Is(err, vegeta.ErrNoMethod) {
log.Fatal("each JSON target needs a \"method\" field")
}
return err
} Prevention
- 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
When it happens
Trigger: A JSON targets entry without a "method" field (and no default method configured on the JSONTargeter) passed to vegeta attack with -format=json.
Common situations: 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.
Understand the failure class
Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.
Related errors
- ErrNoURL
- ErrNoTargets
- rate frequency and time unit must be bigger than zero
- must specify at least resolver address
- lttb: min threshold is 3
AI-assisted analysis of tsenart/vegeta@cf58112690 (2026-08-31).
Data as JSON: /api/errors/cc1e5acc9ba74c06.
Report an issue: GitHub.