go-delve/delve · error

could not find label %q

Error message

could not find label %q

What it means

Removing a pprof label via 'config showPprofLabels -clear <label>' scans the ShowPprofLabels list for an exact match; if the label is not present, 'could not find label %q' is returned. Labels are added with 'config showPprofLabels <label>' and removed only by exact string match.

Source

Thrown at service/dap/config.go:123

	argv := config.SplitQuotedFields(rest, '"')
	if len(argv) == 2 && argv[0] == "-clear" {
		argv = argv[1:]
		delete = true
	}
	switch len(argv) {
	case 0:
		// do nothing, let caller show the current list of labels
		return nil
	case 1:
		if delete {
			for i := range args.ShowPprofLabels {
				if args.ShowPprofLabels[i] == argv[0] {
					copy(args.ShowPprofLabels[i:], args.ShowPprofLabels[i+1:])
					args.ShowPprofLabels = args.ShowPprofLabels[:len(args.ShowPprofLabels)-1]
					return nil
				}
			}
			return fmt.Errorf("could not find label %q", argv[0])
		} else {
			args.ShowPprofLabels = append(args.ShowPprofLabels, argv[0])
		}
	default:
		return errors.New("too many arguments to \"config showPprofLabels\"")
	}
	return nil
}

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Run 'config showPprofLabels' with no arguments to see currently configured labels.
  2. Use the exact label string as added, matching case and spacing.
  3. Use 'config showPprofLabels -clear' (no label) to wipe the whole list instead of removing one by one.
  4. Re-add the label if needed after session restart since the list does not persist.

Example fix

// before
config showPprofLabels -clear goroutine_id
// after
config showPprofLabels -clear goroutineid
Defensive patterns

Strategy: validation

Validate before calling

out := runEval("config showPprofLabels")
labels := parseLabels(out)
if !labels[label] {
    return fmt.Errorf("label %q not configured", label)
}

Prevention

When it happens

Trigger: Evaluating 'config showPprofLabels -clear mylabel' where mylabel was never added, was cleared already, or differs in case/spelling from the stored label.

Common situations: Labels added in a previous debug session are gone after restart; typos or case mismatch ('CPU' vs 'cpu'); attempting to clear a label that comes from the runtime rather than the configured list.

Related errors


AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31). Data as JSON: /api/errors/cc72ca2bf6fc92fd. Report an issue: GitHub.