ipfs/kubo · error

Provide.DHT.DedicatedPeriodicWorkers must be non-negative, g

Error message

Provide.DHT.DedicatedPeriodicWorkers must be non-negative, got %d

What it means

Provide.DHT.DedicatedPeriodicWorkers reserves sweep-mode workers for periodic reprovides; a negative count is invalid because worker counts cannot be negative. ValidateProvideConfig rejects explicitly set negative values (0 is allowed, meaning none reserved).

Source

Thrown at config/provide.go:247

			return fmt.Errorf("Provide.DHT.Interval=0 no longer disables the provide system on its own; set Provide.Enabled explicitly: " +
				"Provide.Enabled=false to fully disable providing, or Provide.Enabled=true to keep ad-hoc 'ipfs provide once' " +
				"and fast-provide-root working while skipping the periodic reprovide schedule")
		}
	}

	// Validate MaxWorkers
	if !cfg.DHT.MaxWorkers.IsDefault() {
		maxWorkers := cfg.DHT.MaxWorkers.WithDefault(DefaultProvideDHTMaxWorkers)
		if maxWorkers <= 0 {
			return fmt.Errorf("Provide.DHT.MaxWorkers must be positive, got %d", maxWorkers)
		}
	}

	// Validate DedicatedPeriodicWorkers
	if !cfg.DHT.DedicatedPeriodicWorkers.IsDefault() {
		workers := cfg.DHT.DedicatedPeriodicWorkers.WithDefault(DefaultProvideDHTDedicatedPeriodicWorkers)
		if workers < 0 {
			return fmt.Errorf("Provide.DHT.DedicatedPeriodicWorkers must be non-negative, got %d", workers)
		}
	}

	// Validate DedicatedBurstWorkers
	if !cfg.DHT.DedicatedBurstWorkers.IsDefault() {
		workers := cfg.DHT.DedicatedBurstWorkers.WithDefault(DefaultProvideDHTDedicatedBurstWorkers)
		if workers < 0 {
			return fmt.Errorf("Provide.DHT.DedicatedBurstWorkers must be non-negative, got %d", workers)
		}
	}

	// Validate MaxProvideConnsPerWorker
	if !cfg.DHT.MaxProvideConnsPerWorker.IsDefault() {
		conns := cfg.DHT.MaxProvideConnsPerWorker.WithDefault(DefaultProvideDHTMaxProvideConnsPerWorker)
		if conns <= 0 {
			return fmt.Errorf("Provide.DHT.MaxProvideConnsPerWorker must be positive, got %d", conns)
		}
	}

View on GitHub (pinned to 329838acdf)

Solutions

  1. Set the value to a non-negative integer (default 2)
  2. Remove the key to use the default
  3. Clamp computed values with max(0, n) in config-generation code

Example fix

// before
"DedicatedPeriodicWorkers": -1
// after
"DedicatedPeriodicWorkers": 2
Defensive patterns

Strategy: validation

Validate before calling

if w := cfg.Provide.DHT.DedicatedPeriodicWorkers; !w.IsDefault() && w.WithDefault(config.DefaultProvideDHTDedicatedPeriodicWorkers) < 0 {
	return errors.New("DedicatedPeriodicWorkers must be non-negative")
}

Try / catch

if err := config.ValidateProvideConfig(cfg.Provide); err != nil {
	if strings.Contains(err.Error(), "DedicatedPeriodicWorkers must be non-negative") {
		cfg.Provide.DHT.DedicatedPeriodicWorkers = nil
	}
	return err
}

Prevention

When it happens

Trigger: Node startup when Provide.DHT.DedicatedPeriodicWorkers is explicitly set to a negative integer, e.g. -1, in the config.

Common situations: Sign typo in hand-edited config; buggy automation subtracting worker counts without clamping at zero.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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