{"record":{"id":"b69c1e186222d009","repo":"crowdsecurity/crowdsec","slug":"invalid-ip-address-range","errorCode":null,"errorMessage":"invalid ip address / range","messagePattern":"invalid ip address / range","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/database/errors.go","lineNumber":19,"sourceCode":"package database\n\nimport \"errors\"\n\nvar (\n\tUserExists        = errors.New(\"user already exist\")\n\tUserNotExists     = errors.New(\"user doesn't exist\")\n\tHashError         = errors.New(\"unable to hash\")\n\tInsertFail        = errors.New(\"unable to insert row\")\n\tQueryFail         = errors.New(\"unable to query\")\n\tUpdateFail        = errors.New(\"unable to update\")\n\tDeleteFail        = errors.New(\"unable to delete\")\n\tItemNotFound      = errors.New(\"object not found\")\n\tParseTimeFail     = errors.New(\"unable to parse time\")\n\tParseDurationFail = errors.New(\"unable to parse duration\")\n\tMarshalFail       = errors.New(\"unable to serialize\")\n\tBulkError         = errors.New(\"unable to insert bulk\")\n\tParseType         = errors.New(\"unable to parse type\")\n\tInvalidIPOrRange  = errors.New(\"invalid ip address / range\")\n\tInvalidFilter     = errors.New(\"invalid filter\")\n)\n","sourceCodeStart":1,"sourceCodeEnd":22,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/database/errors.go#L1-L22","documentation":"InvalidIPOrRange is a sentinel error meaning a filter value that should be an IP address or CIDR range could not be converted by csnet.NewRange. It is returned when applying decision filters or expiring decisions with an unparseable 'ip'/'range' value.","triggerScenarios":"applyDecisionFilter or ExpireDecisionsWithFilter (and decisions.go IP filtering) with value like \"192.168.1.\" (truncated), \"10.0.0.0/33\" (bad prefix), a hostname, or an IPv6 string in an IPv4-only context.","commonSituations":"Hand-edited cscli decisions delete --ip values, scripts interpolating unvalidated user input into IP filters, copy/paste dropping part of a CIDR, hostnames used where only IPs/CIDRs are accepted.","solutions":["Fix the IP/CIDR syntax: valid IPv4/IPv6 or CIDR like 1.2.3.4 or 10.0.0.0/8 (prefix <= 32 or 128).","Validate before calling: net.ParseIP / net.ParseCIDR (or csnet.ParseIP) on the value.","If the input is a hostname, resolve it with net.LookupHost first and use the resulting IP.","Check the wrapped inner error for the exact offending value echoed in the message."],"exampleFix":"// before\nipParam := \"192.168.1.\" // truncated\nerr := client.ExpireDecisionsWithFilter(ctx, map[string][]string{\"ip\": {ipParam}})\n// after\nif net.ParseIP(ipParam) == nil {\n    return fmt.Errorf(\"invalid ip %q\", ipParam)\n}\nerr := client.ExpireDecisionsWithFilter(ctx, map[string][]string{\"ip\": {ipParam}})","handlingStrategy":"validation","validationCode":"// Go: validate IP/CIDR before building filters\nfunc validIPOrRange(s string) bool {\n    if net.ParseIP(s) != nil { return true }\n    _, _, err := net.ParseCIDR(s)\n    return err == nil\n}","typeGuard":null,"tryCatchPattern":"if _, err := client.ExpireDecisionsWithFilter(ctx, filter); err != nil {\n    if errors.Is(err, database.InvalidIPOrRange) {\n        return fmt.Errorf(\"bad ip/range in filter: %w\", err)\n    }\n    return err\n}","preventionTips":["Validate all user-supplied IPs/CIDRs with net.ParseIP/net.ParseCIDR","Resolve hostnames to IPs before using them in filters","Copy full CIDR strings — beware truncated values"],"tags":["database","crowdsec","ip","filter"],"backgroundTag":"invalid-argument-value","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}