{"record":{"id":"b766756be37d99bf","repo":"quarkusio/quarkus","slug":"failed-to-parse-cidr-address-value","errorCode":null,"errorMessage":"Failed to parse CIDR address \"${value}\"","messagePattern":"Failed to parse CIDR address \"(.+?)\"","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/runtime/src/main/java/io/quarkus/runtime/configuration/CidrAddressConverter.java","lineNumber":30,"sourceCode":"import io.smallrye.common.net.Inet;\n\n/**\n * A converter which converts a CIDR address into an instance of {@link CidrAddress}.\n */\n@Priority(DEFAULT_QUARKUS_CONVERTER_PRIORITY)\npublic class CidrAddressConverter implements Converter<CidrAddress>, Serializable {\n\n    private static final long serialVersionUID = 2023552088048952902L;\n\n    @Override\n    public CidrAddress convert(String value) {\n        value = value.trim();\n        if (value.isEmpty()) {\n            return null;\n        }\n        final CidrAddress result = Inet.parseCidrAddress(value);\n        if (result == null) {\n            throw new IllegalArgumentException(\"Failed to parse CIDR address \\\"\" + value + \"\\\"\");\n        }\n        return result;\n    }\n}\n","sourceCodeStart":12,"sourceCodeEnd":35,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/runtime/src/main/java/io/quarkus/runtime/configuration/CidrAddressConverter.java#L12-L35","documentation":"CidrAddressConverter.convert() parses config strings like '10.0.0.0/8' into an io.quarkus.runtime.configuration.CidrAddress via Inet.parseCidrAddress. If parsing returns null (malformed address or prefix), it throws IllegalArgumentException(\"Failed to parse CIDR address \\\"<value>\\\"\").","triggerScenarios":"Configuring a property mapped to CidrAddress (e.g. permitted proxy addresses) with a value missing the /prefix part, an invalid IP, an out-of-range prefix length, or extra characters.","commonSituations":"Entering a bare IP '10.0.0.1' where a CIDR '10.0.0.1/32' is required; IPv6 notation mistakes; copy-paste including whitespace/quotes (though value is trimmed); prefix like '/33'.","solutions":["Include a valid prefix: '10.0.0.0/8', '192.168.1.0/24', single host as 'x.x.x.x/32'.","Verify the IP syntax (IPv4 dotted-quad or valid IPv6) and prefix range 0-32 (or 0-128 for IPv6).","Test the value with Inet.parseCidrAddress or an online CIDR validator.","Quote env-var values properly so no shell characters corrupt the value."],"exampleFix":"# before\nquarkus.http.proxy.trusted-proxies=10.0.0.1\n# after\nquarkus.http.proxy.trusted-proxies=10.0.0.1/32","handlingStrategy":"validation","validationCode":"boolean isValidCidr(String s) {\n    if (s == null) return false;\n    String v = s.trim();\n    int slash = v.indexOf('/');\n    if (slash <= 0) return false;\n    try {\n        java.net.InetAddress ip = java.net.InetAddress.getByName(v.substring(0, slash));\n        int prefix = Integer.parseInt(v.substring(slash + 1));\n        int max = ip.getAddress().length * 8;\n        return prefix >= 0 && prefix <= max;\n    } catch (Exception e) { return false; }\n}","typeGuard":"io.quarkus.runtime.configuration.CidrAddress tryParseCidr(String s) {\n    try { return (s == null || s.isBlank()) ? null : io.quarkus.runtime.net.Inet.parseCidrAddress(s.trim()); }\n    catch (Exception e) { return null; }\n}","tryCatchPattern":"try {\n    // use converted CidrAddress\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Failed to parse CIDR address\")) {\n        log.errorf(\"Bad CIDR in config: %s\", e.getMessage());\n    } else { throw e; }\n}","preventionTips":["Always include the /prefix suffix, use /32 (or /128) for single hosts","Validate prefix length against address family (32 vs 128 bits)","Trim and dequote values coming from env vars"],"tags":["configuration","network","cidr","converter"],"backgroundTag":"invalid-config-value","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}