{"record":{"id":"26fb973c0a87753f","repo":"caddyserver/caddy","slug":"weighted-round-robin-requires-at-least-one-upstrea","errorCode":null,"errorMessage":"weighted_round_robin requires at least one upstream with a positive weight","messagePattern":"weighted_round_robin requires at least one upstream with a positive weight","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/caddyhttp/reverseproxy/selectionpolicies.go","lineNumber":133,"sourceCode":"\t\t\treturn d.Errf(\"invalid weight value '%s': weight should be non-negative\", weight)\n\t\t}\n\t\tr.Weights = append(r.Weights, weightInt)\n\t}\n\treturn nil\n}\n\n// Provision sets up r.\nfunc (r *WeightedRoundRobinSelection) Provision(ctx caddy.Context) error {\n\tfor _, weight := range r.Weights {\n\t\tr.totalWeight += weight\n\t}\n\treturn nil\n}\n\n// Validate ensures that r's configuration is valid\nfunc (r *WeightedRoundRobinSelection) Validate() error {\n\tif r.totalWeight <= 0 {\n\t\treturn fmt.Errorf(\"weighted_round_robin requires at least one upstream with a positive weight\")\n\t}\n\tfor _, weight := range r.Weights {\n\t\tif weight < 0 {\n\t\t\treturn fmt.Errorf(\"weight of an upstream cannot be negative\")\n\t\t}\n\t}\n\treturn nil\n}\n\n// Select returns an available host, if any.\nfunc (r *WeightedRoundRobinSelection) Select(pool UpstreamPool, _ *http.Request, _ http.ResponseWriter) *Upstream {\n\tif len(pool) == 0 {\n\t\treturn nil\n\t}\n\tif len(r.Weights) < 2 {\n\t\treturn pool[0]\n\t}\n\tvar index, totalWeight int","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/modules/caddyhttp/reverseproxy/selectionpolicies.go#L115-L151","documentation":"Error \"weighted_round_robin requires at least one upstream with a positive weight\" thrown in caddyserver/caddy.","triggerScenarios":"Thrown at modules/caddyhttp/reverseproxy/selectionpolicies.go:133 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Give at least one upstream a positive weight in the weighted_round_robin policy."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}