{"record":{"id":"6a206dc68b337b3c","repo":"ipfs/kubo","slug":"invalid-configuration-provide-dht-maxworkers-cann","errorCode":null,"errorMessage":"invalid configuration: Provide.DHT.MaxWorkers cannot be 0 when Provide.DHT.SweepEnabled=true. Set Provide.DHT.MaxWorkers to a positive value (e.g., 16) to control resource usage. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#providedhtmaxworkers","messagePattern":"invalid configuration: Provide\\.DHT\\.MaxWorkers cannot be 0 when Provide\\.DHT\\.SweepEnabled=true\\. Set Provide\\.DHT\\.MaxWorkers to a positive value \\(e\\.g\\., 16\\) to control resource usage\\. Documentation: https://github\\.com/ipfs/kubo/blob/master/docs/config\\.md#providedhtmaxworkers","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/ipfs/kubo/daemon.go","lineNumber":984,"sourceCode":"\t// This should never happen for regular users, but is useful error for people who have Docker orchestration\n\t// that blindly sets config keys (overriding automatic Kubo migration).\n\t//nolint:staticcheck // intentionally checking deprecated fields\n\tif cfg.Provider.Enabled != config.Default || !cfg.Provider.Strategy.IsDefault() || !cfg.Provider.WorkerCount.IsDefault() {\n\t\treturn errors.New(\"deprecated configuration detected. Manually migrate 'Provider' fields to 'Provide' and remove 'Provider' from your config. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#provide\")\n\t}\n\t//nolint:staticcheck // intentionally checking deprecated fields\n\tif !cfg.Reprovider.Interval.IsDefault() || !cfg.Reprovider.Strategy.IsDefault() {\n\t\treturn errors.New(\"deprecated configuration detected. Manually migrate 'Reprovider' fields to 'Provide': Reprovider.Strategy -> Provide.Strategy, Reprovider.Interval -> Provide.DHT.Interval. Remove 'Reprovider' from your config. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#provide\")\n\t}\n\tif cfg.Provide.Strategy.WithDefault(\"\") == \"flat\" {\n\t\treturn errors.New(\"Provide.Strategy='flat' is no longer supported. Use 'all' instead. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#providestrategy\")\n\t}\n\tif cfg.Experimental.StrategicProviding {\n\t\treturn errors.New(\"Experimental.StrategicProviding was removed. Remove it from your config. Documentation: https://github.com/ipfs/kubo/blob/master/docs/experimental-features.md#strategic-providing\")\n\t}\n\tif cfg.Provide.DHT.SweepEnabled.WithDefault(config.DefaultProvideDHTSweepEnabled) &&\n\t\tcfg.Provide.DHT.MaxWorkers.WithDefault(config.DefaultProvideDHTMaxWorkers) == 0 {\n\t\treturn errors.New(\"invalid configuration: Provide.DHT.MaxWorkers cannot be 0 when Provide.DHT.SweepEnabled=true. Set Provide.DHT.MaxWorkers to a positive value (e.g., 16) to control resource usage. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#providedhtmaxworkers\")\n\t}\n\tif routingOption == routingOptionDelegatedKwd && cfg.Provide.Enabled.WithDefault(config.DefaultProvideEnabled) {\n\t\treturn errors.New(\"Routing.Type=delegated does not support content providing. Set Provide.Enabled=false in your config\")\n\t}\n\n\treturn nil\n}\n\nfunc validateDaemonEnvironment() error {\n\tif flag := os.Getenv(\"IPFS_REUSEPORT\"); flag != \"\" {\n\t\treturn errors.New(\"support for IPFS_REUSEPORT was removed. Use LIBP2P_TCP_REUSEPORT instead\")\n\t}\n\treturn nil\n}\n\n// printLibp2pPorts prints which ports are opened to facilitate swarm connectivity.\nfunc printLibp2pPorts(node *core.IpfsNode) {\n\tif !node.IsOnline {","sourceCodeStart":966,"sourceCodeEnd":1002,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/cmd/ipfs/kubo/daemon.go#L966-L1002","documentation":"When the DHT provider sweep system is enabled, at least one worker is required to make progress. validateDaemonConfig rejects Provide.DHT.SweepEnabled=true together with Provide.DHT.MaxWorkers=0, which would silently provide nothing while consuming the sweep schedule.","triggerScenarios":"`ipfs daemon` when Provide.DHT.SweepEnabled resolves to true (explicitly or via default) and Provide.DHT.MaxWorkers is explicitly 0 or resolves to the default that the operator overrode to 0.","commonSituations":"Operators zeroing MaxWorkers to 'disable' providing while leaving SweepEnabled on; config templates setting MaxWorkers=0 for resource limits without disabling the sweep.","solutions":["Set a positive worker count: `ipfs config --json Provide.DHT.MaxWorkers 16`","If no providing is wanted, disable the sweep instead: `ipfs config --json Provide.DHT.SweepEnabled false` (or set Provide.Enabled=false)","Check defaults in docs/config.md#providedhtmaxworkers"],"exampleFix":"// before (config.json)\n\"Provide\": { \"DHT\": { \"SweepEnabled\": true, \"MaxWorkers\": 0 } }\n\n// after\n\"Provide\": { \"DHT\": { \"SweepEnabled\": true, \"MaxWorkers\": 16 } }","handlingStrategy":"validation","validationCode":"// enforce workers>=1 when sweep enabled (mirrors daemon logic)\nsweep=$(jq -r '.Provide.DHT.SweepEnabled // \"<default>\"' \"$IPFS_PATH/config\")\nw=$(jq -r '.Provide.DHT.MaxWorkers // \"<default>\"' \"$IPFS_PATH/config\")\nif [ \"$sweep\" = true ] && { [ \"$w\" = 0 ] || { [ \"$w\" = \"<default>\" ] && [ \"$(jq -r '.Provide.DHT.MaxWorkers // 0' \"$IPFS_PATH/config\")\" = 0 ]; }; }; then echo \"Set Provide.DHT.MaxWorkers>0 or disable SweepEnabled\"; fi","typeGuard":null,"tryCatchPattern":"if err := daemonFunc(...); err != nil {\n    if strings.Contains(err.Error(), \"MaxWorkers cannot be 0\") {\n        log.Fatalf(\"fix Provide.DHT config: %v\", err)\n    }\n}","preventionTips":["Never set MaxWorkers=0 while SweepEnabled=true","To throttle providing, lower workers to a small positive value instead of 0","To stop providing, set Provide.Enabled=false instead","Validate JSON config numerics with jq before deploy"],"tags":["config","validation","provide","resource-limits"],"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"}