tsenart/vegeta · error

invalid report type: %s

Error message

invalid report type: %s

What it means

Returned by the `vegeta report` command when the -type flag value is shorter than 4 characters, i.e. not one of the recognized report types (text, json, histogram, plot). It's an early sanity check on the report type string.

Source

Thrown at report.go:63

	buckets := fs.String("buckets", "", "Histogram buckets, e.g.: \"[0,1ms,10ms]\"")

	fs.Usage = func() {
		fmt.Fprintf(os.Stderr, "%s\n", reportUsage)
	}

	return command{fs, func(args []string) error {
		fs.Parse(args)
		files := fs.Args()
		if len(files) == 0 {
			files = append(files, "stdin")
		}
		return report(files, *typ, *output, *every, *buckets)
	}}
}

func report(files []string, typ, output string, every time.Duration, bucketsStr string) error {
	if len(typ) < 4 {
		return fmt.Errorf("invalid report type: %s", typ)
	}

	dec, mc, err := decoder(files)
	defer mc.Close()
	if err != nil {
		return err
	}

	out, err := file(output, true)
	if err != nil {
		return err
	}
	defer out.Close()

	var (
		rep    vegeta.Reporter
		report vegeta.Report
	)

View on GitHub (pinned to cf58112690)

Solutions

  1. Pass a valid type: text, json, histogram (or plot via the dedicated `vegeta plot` command).
  2. Quote and verify the -type value in shell scripts to avoid empty expansion.
  3. Run `vegeta report -h` to list supported types for your installed version.
  4. Update scripts after vegeta upgrades; type names changed across versions (plot was removed from report).

Example fix

// before
vegeta report -type=j results.bin
// after
vegeta report -type=json results.bin
Defensive patterns

Strategy: validation

Validate before calling

var validTypes = map[string]bool{"text": true, "json": true, "histogram": true}
func validateReportType(t string) error {
    if !validTypes[t] {
        return fmt.Errorf("-type must be one of text|json|histogram, got %q", t)
    }
    return nil
}

Try / catch

if err := runReport(args); err != nil {
    if strings.HasPrefix(err.Error(), "invalid report type") {
        return fmt.Errorf("check -type flag: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: Running `vegeta report -type=xyz ...` (or a typo/empty value with length < 4), e.g. "j", "htm", "".

Common situations: Typos in the -type flag, shell variable defaults expanding to empty, older scripts using removed type names.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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