{"record":{"id":"737e8aaf8200ec4e","repo":"quickwit-oss/quickwit","slug":"ip-range-should-parse","errorCode":null,"errorMessage":"IP range should parse","messagePattern":"IP range should parse","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"quickwit/quickwit-common/src/net.rs","lineNumber":298,"sourceCode":"        [\n            \"0.0.0.0/8\",\n            \"127.0.0.0/8\",\n            \"169.254.0.0/16\",\n            \"192.0.0.0/24\",\n            \"192.0.2.0/24\",\n            \"198.51.100.0/24\",\n            \"2001:10::/28\",\n            \"2001:db8::/32\",\n            \"203.0.113.0/24\",\n            \"240.0.0.0/4\",\n            \"255.255.255.255/32\",\n            \"::/128\",\n            \"::1/128\",\n            \"::ffff:0:0/96\",\n            \"fe80::/10\",\n        ]\n        .iter()\n        .map(|network| network.parse().expect(\"IP range should parse\"))\n        .collect()\n    });\n    NON_FORWARDABLE_NETWORKS\n        .iter()\n        .all(|network| !network.contains(*ip_addr))\n}\n\nfn is_private_ip(ip_addr: &IpAddr) -> bool {\n    static PRIVATE_NETWORKS: LazyLock<Vec<IpNetwork>> = LazyLock::new(|| {\n        [\"192.168.0.0/16\", \"172.16.0.0/12\", \"10.0.0.0/8\", \"fc00::/7\"]\n            .iter()\n            .map(|network| network.parse().expect(\"IP range should parse\"))\n            .collect()\n    });\n    PRIVATE_NETWORKS\n        .iter()\n        .any(|network| network.contains(*ip_addr))\n}","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-common/src/net.rs#L280-L316","documentation":"is_forwardable_ip lazily builds a static list of non-forwardable CIDR networks (loopback, unspecified, link-local, etc.) by parsing hardcoded string literals with `network.parse::<IpNetwork>()`. The literals are compile-time constants known to be valid, so the expect \"IP range should parse\" documents an internal invariant; a panic here is a bug (e.g. typo introduced while editing the list), not user input being rejected.","triggerScenarios":"Only when the hardcoded CIDR literal array is edited to an invalid value (or the IpNetwork parser changes semantics), making parse() fail on first access of the LazyLock.","commonSituations":"Practically never hit by users; seen by developers refactoring net.rs or swapping the ipnetwork crate version with stricter parsing.","solutions":["Check the most recently edited network literal for typos (missing prefix like \"::1/128\" becoming \"::1\").","Verify the ipnetwork crate version still parses the given literals (dependency bump regression).","Keep the expect as-is: it is an intentional compile-data invariant, not a runtime condition."],"exampleFix":"// before (typo)\n\"fe80:/10\",\n// after\n\"fe80::/10\",","handlingStrategy":"validation","validationCode":"\"fe80::/10\".parse::<ipnetwork::IpNetwork>().expect(\"literal must be valid CIDR\") // verified at test time","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add a unit test that parses every entry of the network literal arrays.","Re-run tests after bumping the ipnetwork/ipnet dependency.","Never build these literals from user input — they are constants."],"tags":["network","invariant","parsing"],"backgroundTag":"internal-invariant-violation","analyzedSha":"a39730c5cdcd1a4fe798403737ae293999ea21f8","analyzedAt":"2026-09-08T13:19:37.784Z","contentChangedAt":"2026-09-08T13:19:37.784Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}