{"record":{"id":"5607826c88021495","repo":"ipfs/kubo","slug":"provide-dht-dedicatedperiodicworkers-must-be-non-n","errorCode":null,"errorMessage":"Provide.DHT.DedicatedPeriodicWorkers must be non-negative, got %d","messagePattern":"Provide\\.DHT\\.DedicatedPeriodicWorkers must be non-negative, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/provide.go","lineNumber":247,"sourceCode":"\t\t\treturn fmt.Errorf(\"Provide.DHT.Interval=0 no longer disables the provide system on its own; set Provide.Enabled explicitly: \" +\n\t\t\t\t\"Provide.Enabled=false to fully disable providing, or Provide.Enabled=true to keep ad-hoc 'ipfs provide once' \" +\n\t\t\t\t\"and fast-provide-root working while skipping the periodic reprovide schedule\")\n\t\t}\n\t}\n\n\t// Validate MaxWorkers\n\tif !cfg.DHT.MaxWorkers.IsDefault() {\n\t\tmaxWorkers := cfg.DHT.MaxWorkers.WithDefault(DefaultProvideDHTMaxWorkers)\n\t\tif maxWorkers <= 0 {\n\t\t\treturn fmt.Errorf(\"Provide.DHT.MaxWorkers must be positive, got %d\", maxWorkers)\n\t\t}\n\t}\n\n\t// Validate DedicatedPeriodicWorkers\n\tif !cfg.DHT.DedicatedPeriodicWorkers.IsDefault() {\n\t\tworkers := cfg.DHT.DedicatedPeriodicWorkers.WithDefault(DefaultProvideDHTDedicatedPeriodicWorkers)\n\t\tif workers < 0 {\n\t\t\treturn fmt.Errorf(\"Provide.DHT.DedicatedPeriodicWorkers must be non-negative, got %d\", workers)\n\t\t}\n\t}\n\n\t// Validate DedicatedBurstWorkers\n\tif !cfg.DHT.DedicatedBurstWorkers.IsDefault() {\n\t\tworkers := cfg.DHT.DedicatedBurstWorkers.WithDefault(DefaultProvideDHTDedicatedBurstWorkers)\n\t\tif workers < 0 {\n\t\t\treturn fmt.Errorf(\"Provide.DHT.DedicatedBurstWorkers must be non-negative, got %d\", workers)\n\t\t}\n\t}\n\n\t// Validate MaxProvideConnsPerWorker\n\tif !cfg.DHT.MaxProvideConnsPerWorker.IsDefault() {\n\t\tconns := cfg.DHT.MaxProvideConnsPerWorker.WithDefault(DefaultProvideDHTMaxProvideConnsPerWorker)\n\t\tif conns <= 0 {\n\t\t\treturn fmt.Errorf(\"Provide.DHT.MaxProvideConnsPerWorker must be positive, got %d\", conns)\n\t\t}\n\t}","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/config/provide.go#L229-L265","documentation":"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).","triggerScenarios":"Node startup when Provide.DHT.DedicatedPeriodicWorkers is explicitly set to a negative integer, e.g. -1, in the config.","commonSituations":"Sign typo in hand-edited config; buggy automation subtracting worker counts without clamping at zero.","solutions":["Set the value to a non-negative integer (default 2)","Remove the key to use the default","Clamp computed values with max(0, n) in config-generation code"],"exampleFix":"// before\n\"DedicatedPeriodicWorkers\": -1\n// after\n\"DedicatedPeriodicWorkers\": 2","handlingStrategy":"validation","validationCode":"if w := cfg.Provide.DHT.DedicatedPeriodicWorkers; !w.IsDefault() && w.WithDefault(config.DefaultProvideDHTDedicatedPeriodicWorkers) < 0 {\n\treturn errors.New(\"DedicatedPeriodicWorkers must be non-negative\")\n}","typeGuard":null,"tryCatchPattern":"if err := config.ValidateProvideConfig(cfg.Provide); err != nil {\n\tif strings.Contains(err.Error(), \"DedicatedPeriodicWorkers must be non-negative\") {\n\t\tcfg.Provide.DHT.DedicatedPeriodicWorkers = nil\n\t}\n\treturn err\n}","preventionTips":["Clamp computed worker budgets at zero","Use uint-style thinking: worker counts are never negative","Re-run validation after any automated config rewrite"],"tags":["config","validation","dht","workers"],"backgroundTag":"invalid-config-value","analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}