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
- 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.
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
- 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
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.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Unable to resolve "${value}"
- Unable to create Charset from: '${trimmedCharset}'
- Invalid duration: ${value}
- Failed to load application configuration
- Failed to initialize application configuration
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/b766756be37d99bf.
Report an issue: GitHub.