quarkusio/quarkus · error · IllegalArgumentException

Failed to parse CIDR address "${value}"

Error message

Failed to parse CIDR address "${value}"

What it means

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>\"").

Source

Thrown at core/runtime/src/main/java/io/quarkus/runtime/configuration/CidrAddressConverter.java:30

import io.smallrye.common.net.Inet;

/**
 * A converter which converts a CIDR address into an instance of {@link CidrAddress}.
 */
@Priority(DEFAULT_QUARKUS_CONVERTER_PRIORITY)
public class CidrAddressConverter implements Converter<CidrAddress>, Serializable {

    private static final long serialVersionUID = 2023552088048952902L;

    @Override
    public CidrAddress convert(String value) {
        value = value.trim();
        if (value.isEmpty()) {
            return null;
        }
        final CidrAddress result = Inet.parseCidrAddress(value);
        if (result == null) {
            throw new IllegalArgumentException("Failed to parse CIDR address \"" + value + "\"");
        }
        return result;
    }
}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Include a valid prefix: '10.0.0.0/8', '192.168.1.0/24', single host as 'x.x.x.x/32'.
  2. Verify the IP syntax (IPv4 dotted-quad or valid IPv6) and prefix range 0-32 (or 0-128 for IPv6).
  3. Test the value with Inet.parseCidrAddress or an online CIDR validator.
  4. Quote env-var values properly so no shell characters corrupt the value.

Example fix

# before
quarkus.http.proxy.trusted-proxies=10.0.0.1
# after
quarkus.http.proxy.trusted-proxies=10.0.0.1/32
Defensive patterns

Strategy: validation

Validate before calling

boolean isValidCidr(String s) {
    if (s == null) return false;
    String v = s.trim();
    int slash = v.indexOf('/');
    if (slash <= 0) return false;
    try {
        java.net.InetAddress ip = java.net.InetAddress.getByName(v.substring(0, slash));
        int prefix = Integer.parseInt(v.substring(slash + 1));
        int max = ip.getAddress().length * 8;
        return prefix >= 0 && prefix <= max;
    } catch (Exception e) { return false; }
}

Type guard

io.quarkus.runtime.configuration.CidrAddress tryParseCidr(String s) {
    try { return (s == null || s.isBlank()) ? null : io.quarkus.runtime.net.Inet.parseCidrAddress(s.trim()); }
    catch (Exception e) { return null; }
}

Try / catch

try {
    // use converted CidrAddress
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("Failed to parse CIDR address")) {
        log.errorf("Bad CIDR in config: %s", e.getMessage());
    } else { throw e; }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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'.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/b766756be37d99bf. Report an issue: GitHub.