rakyll/hey · error

could not parse the provided input; input = %v

Error message

could not parse the provided input; input = %v

What it means

parseInputWithRegexp in hey.go validates CLI flag values (such as -H header and -a auth values) against a regular expression and returns this error when FindStringSubmatch finds no matches, i.e. the input does not conform to the expected format. It is a user-input validation error, not a runtime fault: the value passed to the flag simply doesn't match the required pattern. The raw input is included in the message via %v so the offending value can be identified.

Source

Thrown at hey.go:275

	fmt.Fprintf(os.Stderr, "\n")
	os.Exit(1)
}

func usageAndExit(msg string) {
	if msg != "" {
		fmt.Fprintf(os.Stderr, "%s", msg)
		fmt.Fprintf(os.Stderr, "\n\n")
	}
	flag.Usage()
	fmt.Fprintf(os.Stderr, "\n")
	os.Exit(1)
}

func parseInputWithRegexp(input, regx string) ([]string, error) {
	re := regexp.MustCompile(regx)
	matches := re.FindStringSubmatch(input)
	if len(matches) < 1 {
		return nil, fmt.Errorf("could not parse the provided input; input = %v", input)
	}
	return matches, nil
}

type headerSlice []string

func (h *headerSlice) String() string {
	return fmt.Sprintf("%s", *h)
}

func (h *headerSlice) Set(value string) error {
	*h = append(*h, value)
	return nil
}

View on GitHub (pinned to 5626f79b86)

Solutions

  1. Check the flag value against the required format and fix it: headers must be 'Name: Value' with an explicit colon and space, auth must match the expected 'user:password' pattern.
  2. Quote the argument in your shell so special characters or meta characters in headers/auth are passed through intact (e.g. -H 'Content-Type: application/json').
  3. If invoked programmatically, print/inspect the argv actually passed to hey to confirm no argument was dropped or split incorrectly.
  4. If you are the maintainer, consider improving the error to name which flag failed (e.g. wrap with fmt.Errorf("invalid -H value %q: %w", input, err)) for easier diagnosis.

Example fix

// before
$ hey -n 10 -H "Content-Type application/json" https://example.com
// error: could not parse the provided input; input = Content-Type application/json

// after
$ hey -n 10 -H "Content-Type: application/json" https://example.com
Defensive patterns

Strategy: validation

Validate before calling

func validHeader(s string) bool {
	return regexp.MustCompile(`^[^:]+:\s*.+$`).MatchString(s)
}
// check each -H and -a value before invoking hey
if !validHeader(hdr) {
	return fmt.Errorf("invalid -H value %q: must be 'Name: Value'", hdr)
}

Prevention

When it happens

Trigger: Running hey with a -H value that isn't in 'Name: Value' form (e.g. -H 'HeaderName' with no colon, or a missing/empty value), or an -a/--auth value that doesn't match the expected 'username:password' or Basic-auth shape, so the corresponding regexp returns zero submatches.

Common situations: Typing a header flag with a space instead of a colon (-H 'Content-Type application/json' instead of -H 'Content-Type: application/json'), forgetting the colon separator entirely, passing an auth value without ':' for basic auth, quoting/shell-escaping mistakes that mangle the flag value, or automated scripts invoking hey with empty flag values.


AI-assisted analysis of rakyll/hey@5626f79b86 (2026-09-02). Data as JSON: /api/errors/568100a53d4537df. Report an issue: GitHub.