tsenart/vegeta · error

invalid source address expression [%s], expected address:por

Error message

invalid source address expression [%s], expected address:port

What it means

After -connect-to is split into src and dst halves, vegeta validates the source half with net.SplitHostPort. If "host:port" is malformed (too many colons, empty host, unbracketed IPv6), Set returns this error naming the offending source expression.

Source

Thrown at flags.go:196

func (c *connectToFlag) Set(s string) error {
	if c.addrMap == nil {
		return nil
	}

	if *c.addrMap == nil {
		*c.addrMap = make(map[string][]string)
	}

	parts := strings.Split(s, ":")
	if len(parts) != 4 {
		return fmt.Errorf("invalid -connect-to %q, expected format: %s", s, connectToFormat)
	}
	srcAddr := parts[0] + ":" + parts[1]
	dstAddr := parts[2] + ":" + parts[3]

	// Parse source address
	if _, _, err := net.SplitHostPort(srcAddr); err != nil {
		return fmt.Errorf("invalid source address expression [%s], expected address:port", srcAddr)
	}

	// Parse destination address
	if _, _, err := net.SplitHostPort(dstAddr); err != nil {
		return fmt.Errorf("invalid destination address expression [%s], expected address:port", dstAddr)
	}

	(*c.addrMap)[srcAddr] = append((*c.addrMap)[srcAddr], dstAddr)

	return nil
}

View on GitHub (pinned to cf58112690)

Solutions

  1. Write the source as a valid host:port pair, e.g. -connect-to='example.com:80:127.0.0.1:8080'.
  2. Wrap IPv6 literals in brackets: '[::1]:8080'.
  3. Ensure the host portion is non-empty.
  4. Test the pair with net.SplitHostPort in your own tooling before passing it to vegeta.

Example fix

// before
-connect-to='2001:db8::1:80:127.0.0.1:8080'
// after
-connect-to='[2001:db8::1]:80:127.0.0.1:8080'
Defensive patterns

Strategy: validation

Validate before calling

func validSrcAddr(src string) bool {
	_, _, err := net.SplitHostPort(src)
	return err == nil
}
// apply to the first host:port half of -connect-to

Prevention

When it happens

Trigger: Calling ConnectTo.Set where parts[0]+":"+parts[1] fails net.SplitHostPort — e.g. empty host (":80") or too many colons ("a:b:c").

Common situations: IPv6 addresses in the first half without brackets; empty host portion; typos like 'host::port'; programmatic assembly with a missing component.

Related errors


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