golang/go · error

unknown pprof type %s

Error message

unknown pprof type %s

What it means

The `go tool trace` command was invoked with the `-pprof` flag set to a value that is not one of the supported profile types. The tool supports generating four pprof-format profiles from trace data: `net` (network blocking), `sync` (synchronization blocking), `syscall` (syscall blocking), and `sched` (scheduler latency). Any other string passed to `-pprof` triggers this error.

Source

Thrown at src/cmd/trace/main.go:126

	// Handle requests for profiles.
	if *pprofFlag != "" {
		parsed, err := parseTrace(tracef, traceSize)
		if err != nil {
			logAndDie(err)
		}
		var f traceviewer.ProfileFunc
		switch *pprofFlag {
		case "net":
			f = pprofByGoroutine(computePprofIO(), parsed)
		case "sync":
			f = pprofByGoroutine(computePprofBlock(), parsed)
		case "syscall":
			f = pprofByGoroutine(computePprofSyscall(), parsed)
		case "sched":
			f = pprofByGoroutine(computePprofSched(), parsed)
		default:
			logAndDie(fmt.Errorf("unknown pprof type %s\n", *pprofFlag))
		}
		records, err := f(&http.Request{})
		if err != nil {
			logAndDie(fmt.Errorf("failed to generate pprof: %v\n", err))
		}
		if err := traceviewer.BuildProfile(records).Write(os.Stdout); err != nil {
			logAndDie(fmt.Errorf("failed to generate pprof: %v\n", err))
		}
		logAndDie(nil)
	}

	// Debug flags.
	if *debugFlag != "" {
		switch *debugFlag {
		case "parsed":
			logAndDie(debugProcessedEvents(tracef))
		case "wire":
			logAndDie(debugRawEvents(tracef))

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Use one of the four valid values: `net`, `sync`, `syscall`, or `sched`.
  2. Check the help output: `go tool trace -h` to see supported flag values.
  3. If you need CPU or heap profiles, use `go tool pprof` directly instead of `go tool trace -pprof`.
  4. For an overview of all trace data, use `go tool trace <file>` without the `-pprof` flag to open the web UI.

Example fix

# Before: invalid pprof type
go tool trace -pprof=network trace.out   # wrong
go tool trace -pprof=cpu trace.out        # not supported via trace

# After: use a valid type
go tool trace -pprof=net trace.out
go tool trace -pprof=sync trace.out
go tool trace -pprof=syscall trace.out
go tool trace -pprof=sched trace.out
Defensive patterns

Strategy: validation

Validate before calling

// Validate pprof type before passing to go tool trace
validPprofTypes := map[string]bool{"net": true, "sync": true, "syscall": true, "sched": true}
pprofType := *pprofFlag
if !validPprofTypes[pprofType] {
    log.Fatalf("Invalid pprof type '%s'. Valid types: net, sync, syscall, sched", pprofType)
}

Type guard

// Type guard for valid trace pprof types
func isValidTracePprofType(t string) bool {
    switch t {
    case "net", "sync", "syscall", "sched":
        return true
    default:
        return false
    }
}

Prevention

When it happens

Trigger: Fires at trace/main.go:125-126 when the `-pprof` flag value doesn't match any of the four cases in the switch statement (net, sync, syscall, sched). The error includes the invalid flag value. `logAndDie` prints the error and exits.

Common situations: Typing the profile type incorrectly (e.g., 'network' instead of 'net', 'syscalls' instead of 'syscall'). Using an outdated profile type name from an old Go version. Misspelling the type (e.g., 'synch', 'schd'). Passing 'cpu' or 'heap' which are not valid trace-derived profile types (those come from pprof directly, not trace).

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/fbf8e8d235809faf. Report an issue: GitHub.