{"record":{"id":"16ed73e1f2f8d27c","repo":"crowdsecurity/crowdsec","slug":"unable-to-convert-s-to-int-w-w","errorCode":null,"errorMessage":"unable to convert '%s' to int: %w: %w","messagePattern":"unable to convert '(.+?)' to int: %w: %w","errorType":"validation","errorClass":"InvalidIPOrRange","httpStatus":null,"severity":"warning","filePath":"pkg/database/decisionfilter.go","lineNumber":80,"sourceCode":"\t\t\tquery = query.Where(decision.TypeEQ(value[0]))\n\t\tcase \"origins\":\n\t\t\tquery = query.Where(\n\t\t\t\tdecision.OriginIn(strings.Split(value[0], \",\")...),\n\t\t\t)\n\t\tcase \"scenarios_containing\":\n\t\t\tpredicates := decisionPredicatesFromStr(value[0], decision.ScenarioContainsFold)\n\t\t\tquery = query.Where(decision.Or(predicates...))\n\t\tcase \"scenarios_not_containing\":\n\t\t\tpredicates := decisionPredicatesFromStr(value[0], decision.ScenarioContainsFold)\n\t\t\tquery = query.Where(decision.Not(\n\t\t\t\tdecision.Or(\n\t\t\t\t\tpredicates...,\n\t\t\t\t),\n\t\t\t))\n\t\tcase \"ip\", \"range\":\n\t\t\trng, err = csnet.NewRange(value[0])\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"unable to convert '%s' to int: %w: %w\", value[0], err, InvalidIPOrRange)\n\t\t\t}\n\t\tcase \"limit\":\n\t\t\tlimit, err := strconv.Atoi(value[0])\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid limit value: %w: %w\", err, InvalidFilter)\n\t\t\t}\n\n\t\t\tquery = query.Limit(limit)\n\t\tcase \"offset\":\n\t\t\toffset, err := strconv.Atoi(value[0])\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid offset value: %w: %w\", err, InvalidFilter)\n\t\t\t}\n\n\t\t\tquery = query.Offset(offset)\n\t\tcase \"id_gt\":\n\t\t\tid, err := strconv.Atoi(value[0])\n\t\t\tif err != nil {","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/database/decisionfilter.go#L62-L98","documentation":"applyDecisionFilter fails when the 'ip' or 'range' query parameter cannot be parsed into a network range by csnet.NewRange. The message's 'to int' wording is legacy/misleading; the real issue is an invalid IP address or CIDR value, wrapped with sentinel InvalidIPOrRange.","triggerScenarios":"Calling LAPI decision endpoints with ?ip=not-an-ip, ?range=10.0.0/24 (bad CIDR), ?ip=999.1.1.1, or an IPv6 with wrong syntax.","commonSituations":"Hand-built curl commands with typos in CIDR notation; scripts interpolating empty strings for ip/range; mixing prefix lengths wrong (e.g. /33); passing a hostname instead of an IP.","solutions":["Validate the value is a valid IP or CIDR (net.ParseIP / net.ParseCIDR) before sending.","Use full CIDR form for ranges: 10.0.0.0/24, not 10.0.0/24.","Remove the ip/range parameter to query without an IP filter.","For IPv6, ensure correct compressed notation (e.g. 2001:db8::/32)."],"exampleFix":"// before\nGET /v1/decisions?range=192.168.1.0/33\n// after\nGET /v1/decisions?range=192.168.1.0/24","handlingStrategy":"validation","validationCode":"func validIPOrRange(v string) bool {\n    if v == \"\" { return false }\n    if strings.Contains(v, \"/\") {\n        _, _, err := net.ParseCIDR(v)\n        return err == nil\n    }\n    return net.ParseIP(v) != nil\n}","typeGuard":null,"tryCatchPattern":"if !validIPOrRange(ipParam) {\n    return fmt.Errorf(\"refusing LAPI call: %q is not an IP or CIDR\", ipParam)\n}\nresp, err := lapi.GetDecisions(ctx, models.GetDecisionsOpts{IP: &ipParam})\nif err != nil && strings.Contains(err.Error(), \"InvalidIPOrRange\") {\n    return fmt.Errorf(\"bad ip/range %q: %w\", ipParam, err)\n}","preventionTips":["Validate IPs/CIDRs with net.ParseIP/net.ParseCIDR before sending","Use full CIDR notation for ranges","Never pass hostnames where an IP is expected","Handle empty strings explicitly instead of interpolating them"],"tags":["api","network","query-parameter","validation"],"backgroundTag":"invalid-query-parameter","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}