{"record":{"id":"17486891cedb49c0","repo":"ipfs/kubo","slug":"provide-dht-interval-must-be-non-negative-got-v","errorCode":null,"errorMessage":"Provide.DHT.Interval must be non-negative, got %v","messagePattern":"Provide\\.DHT\\.Interval must be non-negative, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/provide.go","lineNumber":218,"sourceCode":"\t\treturn fmt.Errorf(\"Provide.Strategy: %w\", err)\n\t}\n\n\t// Validate Provide.BloomFPRate\n\tif !cfg.BloomFPRate.IsDefault() {\n\t\trate := cfg.BloomFPRate.WithDefault(DefaultProvideBloomFPRate)\n\t\tif rate < MinProvideBloomFPRate {\n\t\t\treturn fmt.Errorf(\"Provide.BloomFPRate must be >= %d (1 in 1M), got %d\", MinProvideBloomFPRate, rate)\n\t\t}\n\t}\n\n\t// Validate Provide.DHT.Interval\n\tif !cfg.DHT.Interval.IsDefault() {\n\t\tinterval := cfg.DHT.Interval.WithDefault(DefaultProvideDHTInterval)\n\t\tif interval > amino.DefaultProvideValidity {\n\t\t\treturn fmt.Errorf(\"Provide.DHT.Interval (%v) must be less than or equal to DHT provider record validity (%v)\", interval, amino.DefaultProvideValidity)\n\t\t}\n\t\tif interval < 0 {\n\t\t\treturn fmt.Errorf(\"Provide.DHT.Interval must be non-negative, got %v\", interval)\n\t\t}\n\t\t// Provide.DHT.Interval=0 used to disable the entire provide system as a\n\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() {","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/config/provide.go#L200-L236","documentation":"A negative Provide.DHT.Interval is meaningless: the interval schedules periodic reprovide rounds in time. ValidateProvideConfig rejects negative durations explicitly, after checking the upper bound against the DHT provider record validity.","triggerScenarios":"Node startup when Provide.DHT.Interval is explicitly set to a negative duration such as \"-1h\", typically via a malformed JSON duration string in the config or a buggy config-generation script.","commonSituations":"Sign typo when hand-editing the config; script computing an interval from a signed offset; misunderstanding of duration formatting in the JSON config.","solutions":["Set Provide.DHT.Interval to a non-negative duration (e.g. \"22h\" or \"0s\" for the special zero semantics)","Remove the key to use the default 22h interval","If zero was intended to disable reproviding, also set Provide.Enabled explicitly (see the Interval=0 error)"],"exampleFix":"// before\n\"Interval\": \"-1h\"\n// after\n\"Interval\": \"0s\"","handlingStrategy":"validation","validationCode":"if iv := cfg.Provide.DHT.Interval; !iv.IsDefault() && iv.WithDefault(config.DefaultProvideDHTInterval) < 0 {\n\treturn errors.New(\"Provide.DHT.Interval must be non-negative\")\n}","typeGuard":null,"tryCatchPattern":"if err := config.ValidateProvideConfig(cfg.Provide); err != nil {\n\tif strings.Contains(err.Error(), \"must be non-negative\") {\n\t\tcfg.Provide.DHT.Interval = nil\n\t}\n\treturn err\n}","preventionTips":["Use standard duration strings (\"22h\", \"0s\") and check for accidental '-' signs","Validate generated configs before writing them to the repo","Treat \"0s\" as the special disable-reprovide value, not a negative one"],"tags":["config","validation","dht"],"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"}