{"record":{"id":"d37b6182a1c81a25","repo":"crowdsecurity/crowdsec","slug":"invalid-ip-s-for-bot-entry-s-in-s-w","errorCode":null,"errorMessage":"invalid IP '%s' for bot entry '%s' in %s: %w","messagePattern":"invalid IP '(.+?)' for bot entry '(.+?)' in (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/exprhelpers/botfile.go","lineNumber":88,"sourceCode":"\t\t\treturn fmt.Errorf(\"invalid user_agent regex for bot entry '%s' in %s: %w\", entry.Name, filename, err)\n\t\t}\n\t}\n\n\tfor _, p := range entry.Paths {\n\t\tre, err := compileBotRegex(p)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid path regex '%s' for bot entry '%s' in %s: %w\", p, entry.Name, filename, err)\n\t\t}\n\n\t\tentry.pathRegexes = append(entry.pathRegexes, re)\n\t}\n\n\tentry.ipSet = make(map[netip.Addr]struct{}, len(entry.IPs))\n\n\tfor _, ip := range entry.IPs {\n\t\taddr, err := netip.ParseAddr(ip)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid IP '%s' for bot entry '%s' in %s: %w\", ip, entry.Name, filename, err)\n\t\t}\n\n\t\tentry.ipSet[addr.Unmap()] = struct{}{}\n\t}\n\n\tfor _, r := range entry.Ranges {\n\t\tprefix, err := netip.ParsePrefix(r)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid CIDR range '%s' for bot entry '%s' in %s: %w\", r, entry.Name, filename, err)\n\t\t}\n\n\t\tentry.prefixes = append(entry.prefixes, prefix.Masked())\n\t}\n\n\tfor _, p := range entry.RDNS {\n\t\t// an empty pattern matches every PTR-confirmed host: almost\n\t\t// certainly a mistake, reject it\n\t\tif p == \"\" {","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/exprhelpers/botfile.go#L70-L106","documentation":"botFileInit parses each element of the entry's \"ips\" array with netip.ParseAddr and stores it in an in-memory set. This error is thrown when a listed IP is not a valid textual IP address (IPv4 or IPv6). The wrapped error is the netip.ParseAddr parse failure, and the message identifies the bad value, entry, and file.","triggerScenarios":"A bots JSONL entry contains \"ips\":[...] with a malformed element: a CIDR like \"1.2.3.0/24\" (belongs in ranges), a hostname, \"1.2.3.256\", an empty string, or an address with a zone like \"fe80::1%eth0\".","commonSituations":"Putting CIDR ranges into \"ips\" instead of \"ranges\"; copy-pasting hostnames from a blocklist meant for DNS resolution; trailing whitespace or invisible characters; octet overflow typos; export scripts writing placeholder values like \"<ip>\".","solutions":["Fix the malformed value to a bare IPv4/IPv6 address, e.g. \"192.0.2.10\" or \"2001:db8::1\".","If the value is a network like \"1.2.3.0/24\", move it to the \"ranges\" array — ParseAddr rejects CIDR notation.","If it is a hostname, resolve it to an address or drop it; this loader does no DNS resolution for ips.","Strip whitespace/BOM/quotes from each element; verify with `python3 -c \"import ipaddress; ipaddress.ip_address('VALUE')\"` or similar.","Remove empty strings from the ips array."],"exampleFix":"// before\n{\"name\":\"badbot\",\"ips\":[\"203.0.113.0/24\",\"203.0.113.256\"]}\n// after\n{\"name\":\"badbot\",\"ips\":[],\"ranges\":[\"203.0.113.0/24\"]}","handlingStrategy":"validation","validationCode":"for _, ip := range entry.IPs {\n\tif _, err := netip.ParseAddr(strings.TrimSpace(ip)); err != nil {\n\t\t// reject before FileInit\n\t}\n}\nvalid := err == nil","typeGuard":null,"tryCatchPattern":"if err := exprhelpers.FileInit(botFile, \"bots\"); err != nil {\n\tvar perr *net.ParseError\n\tif strings.Contains(err.Error(), \"invalid IP\") {\n\t\tlog.Errorf(\"bad ips element: %v\", err)\n\t}\n\t_ = perr\n\treturn err\n}","preventionTips":["Keep single addresses in ips and networks in ranges — never mix.","Trim whitespace and strip quotes when generating entries from external lists.","Validate each element with netip.ParseAddr (or ipaddress.ip_address) in CI.","Reject hostnames at ingestion time; resolve them upstream if needed."],"tags":["go","ip-address","validation","data-files"],"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"}