{"record":{"id":"3d96e01e05ec4ce7","repo":"OpenFeign/feign","slug":"formatted-errormessagetemplate-with-errormessagear","errorCode":null,"errorMessage":"formatted errorMessageTemplate with errorMessageArgs","messagePattern":"formatted errorMessageTemplate with errorMessageArgs","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/feign/Util.java","lineNumber":117,"sourceCode":"  private static final Pattern XML_CONTENT_TYPE =\n      Pattern.compile(\"(?i)\\\\w+/(?:[\\\\w._-]+\\\\+)?xml.*\");\n\n  /** Type literal for {@code Map<String, ?>}. */\n  public static final Type MAP_STRING_WILDCARD =\n      new Types.ParameterizedTypeImpl(\n          null,\n          Map.class,\n          String.class,\n          new Types.WildcardTypeImpl(new Type[] {Object.class}, new Type[0]));\n\n  private Util() { // no instances\n  }\n\n  /** Copy of {@code com.google.common.base.Preconditions#checkArgument}. */\n  public static void checkArgument(\n      boolean expression, String errorMessageTemplate, Object... errorMessageArgs) {\n    if (!expression) {\n      throw new IllegalArgumentException(format(errorMessageTemplate, errorMessageArgs));\n    }\n  }\n\n  /** Copy of {@code com.google.common.base.Preconditions#checkNotNull}. */\n  public static <T> T checkNotNull(\n      T reference, String errorMessageTemplate, Object... errorMessageArgs) {\n    if (reference == null) {\n      // If either of these parameters is null, the right thing happens anyway\n      throw new NullPointerException(format(errorMessageTemplate, errorMessageArgs));\n    }\n    return reference;\n  }\n\n  /** Copy of {@code com.google.common.base.Preconditions#checkState}. */\n  public static void checkState(\n      boolean expression, String errorMessageTemplate, Object... errorMessageArgs) {\n    if (!expression) {\n      throw new IllegalStateException(format(errorMessageTemplate, errorMessageArgs));","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/OpenFeign/feign/blob/e2a1e27560a1e68840c34f031afca88b36096e30/core/src/main/java/feign/Util.java#L99-L135","documentation":"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.","triggerScenarios":"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.","commonSituations":"Feign.builder().target(...) with blank name/url; RequestTemplate with invalid inputs; misuse of internal Util-validated helpers when composing templates or encoders.","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"],"exampleFix":"// before\nFeign.builder().target(\"\", \"\"); // checkArgument fails\n// after\nFeign.builder().target(\"my-service\", \"https://api.example.com\");","handlingStrategy":"validation","validationCode":"if (name == null || name.isEmpty()) throw new IllegalArgumentException(\"target name must be non-empty\");","typeGuard":"boolean validTarget(String name, String url) { return name != null && !name.isEmpty() && url != null && !url.isEmpty(); }","tryCatchPattern":"try { builder.target(name, url); } catch (IllegalArgumentException e) { throw new ConfigException(\"Invalid Feign target: \" + e.getMessage(), e); }","preventionTips":["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"],"tags":["precondition","illegal-argument","validation","java"],"backgroundTag":"invalid-argument-value","analyzedSha":"e2a1e27560a1e68840c34f031afca88b36096e30","analyzedAt":"2026-09-10T12:37:37.238Z","contentChangedAt":"2026-09-10T12:37:37.238Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}