OpenFeign/feign · error · IllegalArgumentException

a value is required.

Error message

a value is required.

What it means

feign.template.Literal represents a fixed (non-variable) text segment inside a request template. Its package-private constructor rejects null or empty strings, since a Literal with no content is meaningless. IllegalArgumentException('a value is required.') is thrown at construction time.

Solutions

  1. Ensure the string passed to the Literal constructor is non-null and non-empty; filter out empty chunks before constructing.
  2. If parsing your own template, guard each segment: only create a Literal when segment.length() > 0.
  3. Catch IllegalArgumentException around template construction to detect malformed template input and surface a clearer message to the user.

Example fix

// before
new Literal(chunk); // chunk may be ""
// after
if (chunk != null && !chunk.isEmpty()) {
  new Literal(chunk);
}
Defensive patterns

Strategy: validation

Validate before calling

if (value == null || value.isEmpty()) {
  return; // skip empty literal segment
}

Type guard

static boolean isNonEmptyLiteral(String s) {
  return s != null && !s.isEmpty();
}

Try / catch

try {
  new Literal(segment);
} catch (IllegalArgumentException e) {
  // segment was null/empty; skip or log malformed template chunk
}

Prevention

When it happens

Trigger: Constructing Literal directly (within the template package) with a null or "" value. Indirectly, via template parsing code that chunked a template into literal/variable segments and produced an empty literal chunk (e.g. adjacent variables like {a}{b}, or a template starting/ending with a variable in some code paths).

Common situations: Feign URI template strings with empty segments or adjacent placeholders; custom template parsing/extending code in the feign.template package; unit-testing template internals with empty strings.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of OpenFeign/feign@e2a1e27560 (2026-09-10). Data as JSON: /api/errors/bd5cfe5900869681. Report an issue: GitHub.

Appendix: source

Thrown at core/src/main/java/feign/template/Literal.java:40

  /**
   * Create a new Literal.
   *
   * @param value of the literal.
   * @return the new Literal.
   */
  public static Literal create(String value) {
    return new Literal(value);
  }

  /**
   * Create a new Literal.
   *
   * @param value of the literal.
   */
  Literal(String value) {
    if (value == null || value.isEmpty()) {
      throw new IllegalArgumentException("a value is required.");
    }
    this.value = value;
  }

  @Override
  public String getValue() {
    return this.value;
  }
}

View on GitHub (pinned to e2a1e27560)