{"record":{"id":"52d9617facd17f6c","repo":"ipfs/kubo","slug":"version-swarmcheckpercentthreshold-must-be-between","errorCode":null,"errorMessage":"Version.SwarmCheckPercentThreshold must be between 1 and 100","messagePattern":"Version\\.SwarmCheckPercentThreshold must be between 1 and 100","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/version.go","lineNumber":282,"sourceCode":"\t\t\tprocessPeerstoreEntry(p)\n\t\t}\n\t} else if nd.DHT != nil && nd.DHT.WAN != nil {\n\t\tfor _, pi := range nd.DHT.WAN.RoutingTable().GetPeerInfos() {\n\t\t\tprocessPeerstoreEntry(pi.Id)\n\t\t}\n\t} else if nd.DHT != nil && nd.DHT.LAN != nil {\n\t\tfor _, pi := range nd.DHT.LAN.RoutingTable().GetPeerInfos() {\n\t\t\tprocessPeerstoreEntry(pi.Id)\n\t\t}\n\t} else {\n\t\treturn VersionCheckOutput{}, errors.New(\"could not perform version check due to missing or incompatible DHT configuration\")\n\t}\n\n\tif minPercent < 1 || minPercent > 100 {\n\t\tif minPercent == 0 {\n\t\t\tminPercent = config.DefaultSwarmCheckPercentThreshold\n\t\t} else {\n\t\t\treturn VersionCheckOutput{}, errors.New(\"Version.SwarmCheckPercentThreshold must be between 1 and 100\")\n\t\t}\n\t}\n\n\tminFraction := float64(minPercent) / 100.0\n\n\t// UpdateAvailable flag is set only if minFraction was reached\n\tgreaterFraction := float64(withGreaterVersion) / float64(totalPeersSampled)\n\n\t// Gathered metric are returned every time\n\treturn VersionCheckOutput{\n\t\tUpdateAvailable:    (greaterFraction >= minFraction),\n\t\tRunningVersion:     ourVersion.String(),\n\t\tGreatestVersion:    greatestVersionSeen.String(),\n\t\tPeersSampled:       totalPeersSampled,\n\t\tWithGreaterVersion: withGreaterVersion,\n\t}, nil\n}\n","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/version.go#L264-L300","documentation":"DetectNewKuboVersion takes minPercent, the configured Version.SwarmCheckPercentThreshold, and requires it to be between 1 and 100. Zero falls back to the built-in default, but any other out-of-range value is rejected with this error. It is a configuration validation error, not a runtime failure.","triggerScenarios":"'ipfs version check --threshold N' with N outside 1-100 (excluding 0), or a config file where Version.SwarmCheckPercentThreshold is negative or greater than 100 (e.g. a fraction like 0.5 written where a percent integer is expected).","commonSituations":"Users writing 0.1 (meaning 10%) instead of 10; scripting the check with a computed threshold that can go negative; copying a config snippet with a malformed threshold value.","solutions":["Set Version.SwarmCheckPercentThreshold to an integer between 1 and 100 (e.g. 10 for 10%)","If you want the default, remove the key or set it to 0 explicitly","Convert fractional intentions: 0.5 -> 50, 0.1 -> 10","Pass --threshold with a valid integer when invoking 'ipfs version check'"],"exampleFix":"// before\nipfs config --json Version.SwarmCheckPercentThreshold 0.5\n// after\nipfs config --json Version.SwarmCheckPercentThreshold 50","handlingStrategy":"validation","validationCode":"cfg, _ := node.Repo.Config()\np := cfg.Version.SwarmCheckPercentThreshold\nif p < 0 || p > 100 {\n    return fmt.Errorf(\"SwarmCheckPercentThreshold must be 0-100, got %d\", p)\n}","typeGuard":null,"tryCatchPattern":"out, err := DetectNewKuboVersion(nd, pct)\nif err != nil && strings.Contains(err.Error(), \"must be between 1 and 100\") {\n    // retry with default threshold\n    return DetectNewKuboVersion(nd, 0)\n}\nreturn out, err","preventionTips":["Treat SwarmCheckPercentThreshold as an integer percent (1-100), never a fraction","Validate config before passing thresholds into commands","Use 0 explicitly when you want the default"],"tags":["configuration","version-check","validation"],"backgroundTag":"config-value-out-of-range","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"}