{"record":{"id":"3598bec64b8166c3","repo":"ipfs/kubo","slug":"provide-dht-maxworkers-must-be-positive-got-d","errorCode":null,"errorMessage":"Provide.DHT.MaxWorkers must be positive, got %d","messagePattern":"Provide\\.DHT\\.MaxWorkers must be positive, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/provide.go","lineNumber":239,"sourceCode":"\t\t// side effect. It now disables only the periodic reprovide schedule:\n\t\t// new CIDs still announce via fast-provide-root and 'ipfs provide once'.\n\t\t// Operators upgrading from earlier kubo versions must opt in to one of\n\t\t// the two semantics by setting Provide.Enabled explicitly:\n\t\t//   - Provide.Enabled=false fully disables providing (the old behaviour).\n\t\t//   - Provide.Enabled=true keeps ad-hoc providing while disabling the\n\t\t//     periodic reprovide schedule.\n\t\tif interval == 0 && cfg.Enabled == Default {\n\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}","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/config/provide.go#L221-L257","documentation":"Provide.DHT.MaxWorkers sizes the worker pool for provide operations; zero or negative values would deadlock or make no progress. ValidateProvideConfig requires an explicitly set MaxWorkers to be strictly positive.","triggerScenarios":"Node startup when Provide.DHT.MaxWorkers is explicitly set (non-default) to 0 or a negative integer in the config.","commonSituations":"Operator setting MaxWorkers to 0 intending to disable providing (the correct switch is Provide.Enabled=false); script-generated config computing a zero worker count from an empty value; sign errors.","solutions":["Set Provide.DHT.MaxWorkers to a positive integer (default 16)","To disable providing entirely, remove MaxWorkers and set Provide.Enabled=false instead","Clamp the value in any config-generation script to >= 1"],"exampleFix":"// before\n\"MaxWorkers\": 0\n// after\n\"MaxWorkers\": 16","handlingStrategy":"validation","validationCode":"if mw := cfg.Provide.DHT.MaxWorkers; !mw.IsDefault() && mw.WithDefault(config.DefaultProvideDHTMaxWorkers) <= 0 {\n\treturn errors.New(\"MaxWorkers must be positive\")\n}","typeGuard":null,"tryCatchPattern":"if err := config.ValidateProvideConfig(cfg.Provide); err != nil {\n\tif strings.Contains(err.Error(), \"MaxWorkers must be positive\") {\n\t\tcfg.Provide.DHT.MaxWorkers = nil // default 16\n\t}\n\treturn err\n}","preventionTips":["Never use MaxWorkers=0 to disable providing; use Provide.Enabled=false","Clamp worker counts to >= 1 in config-generation scripts","Keep the default 16 unless you have measured a need to change it"],"tags":["config","validation","dht","workers"],"backgroundTag":"config-value-below-minimum","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"}