ipfs/kubo · error

unknown collector '%s'

Error message

unknown collector '%s'

What it means

runProfile validates that every collector name in p.opts.Collectors exists in the collectors registry; an unknown name returns "unknown collector '<name>'" before any collection runs. This is a configuration/typo error, not a runtime fault.

Source

Thrown at profile/profile.go:145

	archive *zip.Writer
	opts    Options
}

func (p *profiler) runProfile(ctx context.Context) error {
	type profileResult struct {
		fName string
		buf   *bytes.Buffer
		err   error
	}

	ctx, cancelFn := context.WithCancel(ctx)
	defer cancelFn()

	collectorsToRun := make([]collector, len(p.opts.Collectors))
	for i, name := range p.opts.Collectors {
		c, ok := collectors[name]
		if !ok {
			return fmt.Errorf("unknown collector '%s'", name)
		}
		collectorsToRun[i] = c
	}

	results := make(chan profileResult, len(p.opts.Collectors))
	wg := sync.WaitGroup{}
	for _, c := range collectorsToRun {
		if !c.enabledFunc(p.opts) {
			continue
		}

		fName := c.outputFileName()

		wg.Add(1)
		go func(c collector) {
			defer wg.Done()
			logger.Infow("collecting profile", "File", fName)
			defer logger.Infow("profile done", "File", fName)

View on GitHub (pinned to 329838acdf)

Solutions

  1. Correct the collector name to one of the registered names in profile/profile.go's collectors map
  2. List valid names from the collectors map (or the command's help output) before configuring
  3. If a collector was removed in an upgrade, migrate the profile config to its replacement
  4. Validate names at config-load time so bad profiles fail early with a clear message

Example fix

// before
p, _ := profile.Setup("cpu,netwrok,locks") // typo
// after
p, _ := profile.Setup("cpu,network,locks")
Defensive patterns

Strategy: validation

Validate before calling

valid := map[string]bool{"cpu": true, "heap": true, "goroutines": true /* see collectors map */}
for _, name := range collectors {
    if !valid[name] { return fmt.Errorf("unknown collector %q", name) }
}

Prevention

When it happens

Trigger: Calling WriteProfiles with opts.Collectors containing a name not registered in the collectors map (typo, renamed collector, or collector removed in a newer/older version).

Common situations: Debug profiling requests with hand-written collector names, API clients built against a different kubo version where the collector list changed, or programmatic profile config assembled from stale docs.

Related errors


AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03). Data as JSON: /api/errors/c0c29f448033ba0e. Report an issue: GitHub.