OpenFeign/feign · error · IllegalArgumentException
formatted errorMessageTemplate with errorMessageArgs
Error message
formatted errorMessageTemplate with errorMessageArgs
What it means
Util.checkArgument is Feign's Guava-style precondition: it throws IllegalArgumentException with a formatted message when the given boolean expression is false. The message template uses %s placeholders filled by errorMessageArgs. This is a guard against invalid caller-supplied arguments.
Solutions
- Read the formatted message to see which precondition failed
- Correct the invalid argument before calling the API (non-empty, in-range values)
- Validate inputs in your own code before invoking Feign's builder/target APIs
Example fix
// before
Feign.builder().target("", ""); // checkArgument fails
// after
Feign.builder().target("my-service", "https://api.example.com"); Defensive patterns
Strategy: validation
Validate before calling
if (name == null || name.isEmpty()) throw new IllegalArgumentException("target name must be non-empty"); Type guard
boolean validTarget(String name, String url) { return name != null && !name.isEmpty() && url != null && !url.isEmpty(); } Try / catch
try { builder.target(name, url); } catch (IllegalArgumentException e) { throw new ConfigException("Invalid Feign target: " + e.getMessage(), e); } Prevention
- Validate builder inputs before calling Feign APIs
- Never pass empty strings where non-empty is required
- Keep a small validation helper for your Feign configs
When it happens
Trigger: Any Feign API validated with Util.checkArgument receiving an invalid argument, e.g. empty strings for target names/URLs, negative values, or null/empty collections passed to builders and RequestTemplate methods.
Common situations: Feign.builder().target(...) with blank name/url; RequestTemplate with invalid inputs; misuse of internal Util-validated helpers when composing templates or encoders.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Expected a Class, ParameterizedType, or GenericArrayType…
- an expression is required.
- Status Code [ ] has already been declared to throw [ ] and…
- Cannot generate exception - check constructor parameter…
- Too many constructors marked with @FeignExceptionConstructor
AI-assisted analysis of OpenFeign/feign@e2a1e27560 (2026-09-10).
Data as JSON: /api/errors/3d96e01e05ec4ce7.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/feign/Util.java:117
private static final Pattern XML_CONTENT_TYPE =
Pattern.compile("(?i)\\w+/(?:[\\w._-]+\\+)?xml.*");
/** Type literal for {@code Map<String, ?>}. */
public static final Type MAP_STRING_WILDCARD =
new Types.ParameterizedTypeImpl(
null,
Map.class,
String.class,
new Types.WildcardTypeImpl(new Type[] {Object.class}, new Type[0]));
private Util() { // no instances
}
/** Copy of {@code com.google.common.base.Preconditions#checkArgument}. */
public static void checkArgument(
boolean expression, String errorMessageTemplate, Object... errorMessageArgs) {
if (!expression) {
throw new IllegalArgumentException(format(errorMessageTemplate, errorMessageArgs));
}
}
/** Copy of {@code com.google.common.base.Preconditions#checkNotNull}. */
public static <T> T checkNotNull(
T reference, String errorMessageTemplate, Object... errorMessageArgs) {
if (reference == null) {
// If either of these parameters is null, the right thing happens anyway
throw new NullPointerException(format(errorMessageTemplate, errorMessageArgs));
}
return reference;
}
/** Copy of {@code com.google.common.base.Preconditions#checkState}. */
public static void checkState(
boolean expression, String errorMessageTemplate, Object... errorMessageArgs) {
if (!expression) {
throw new IllegalStateException(format(errorMessageTemplate, errorMessageArgs));View on GitHub (pinned to e2a1e27560)