tsenart/vegeta · error

ErrNoURL

ErrNoURL

Error message

target: required url is missing

What it means

ErrNoURL is returned by the JSONTargeter when a decoded Target has no URL set. Without a URL vegeta cannot construct the attack request.

Source

Thrown at lib/targets.go:99

				}
			}
		}

		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) error

// Decode is a convenience method that calls the underlying Targeter function.
func (tr Targeter) Decode(t *Target) error {

View on GitHub (pinned to cf58112690)

Solutions

  1. Add a "url" field to each JSON target: {"method":"GET","url":"http://host/path"}.
  2. Configure JSONTargeter with a default URL/base so targets only carry paths.
  3. Validate the JSON targets file with jq or a schema check before running the attack.

Example fix

// before
{"method": "GET"}
// 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.URL == "" { return vegeta.ErrNoURL }

Try / catch

if err := vegeta.ReadAllTargets(f, vegeta.JSONTargetFormat, &targets); err != nil {
    if errors.Is(err, vegeta.ErrNoURL) {
        log.Fatal("each JSON target needs a \"url\" field")
    }
    return err
}

Prevention

When it happens

Trigger: A JSON targets entry without a "url" field (and no default URL configured on the JSONTargeter), e.g. `-format=json` with malformed target objects.

Common situations: 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.

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


AI-assisted analysis of tsenart/vegeta@cf58112690 (2026-08-31). Data as JSON: /api/errors/c4d405cee3fc8992. Report an issue: GitHub.