Skip to content

Make Expressions max length configurable (fixes #2916)#3422

Merged
velo merged 1 commit into
OpenFeign:masterfrom
seonwooj0810:fix/issue-2916-configurable-expression-max-length
Jun 19, 2026
Merged

Make Expressions max length configurable (fixes #2916)#3422
velo merged 1 commit into
OpenFeign:masterfrom
seonwooj0810:fix/issue-2916-configurable-expression-max-length

Conversation

@seonwooj0810

Copy link
Copy Markdown
Contributor

Fixes #2916

Problem

feign.template.Expressions hard-codes the maximum length of a single template expression to MAX_EXPRESSION_LENGTH = 10000. Any expression longer than that fails with IllegalArgumentException: expression is too long. Max length: 10000, with no way to raise or disable the limit. As noted in the issue, applications that legitimately need longer expressions have no escape hatch.

Change

  • The limit is now read from the feign.template.expression.maxLength system property, defaulting to 10000 (unchanged behavior).
  • Setting the property to 0 (or any non-positive value) disables the length check entirely, as requested in the issue.

The constant was used in a single place (Expressions.create), so the change is self-contained and the default keeps existing behavior intact.

Tests

Added ExpressionsTest cases:

  • tooLongExpressionFailsWithDefaultLimit — default 10000 limit still rejects over-long expressions.
  • maxExpressionLengthIsConfigurable — a custom limit is honored (Max length: 5).
  • lengthCheckCanBeDisabled — with the property set to 0, an expression beyond the default limit is accepted.

Verification done: built and ran ./mvnw -pl core -am test -Dtest=ExpressionsTest (7/7 pass) and validated formatting with the project's git-code-format-maven-plugin:validate-code-format. All commits are DCO signed-off.

The maximum length of a single template expression was hard-coded to
10000 characters in feign.template.Expressions, throwing
IllegalArgumentException for anything longer with no way to opt out.

Make the limit configurable through the
"feign.template.expression.maxLength" system property (default 10000),
and allow disabling the check entirely by setting it to a non-positive
value.

Fixes OpenFeign#2916

Signed-off-by: seonwoo_jung <79202163+seonwooj0810@users.noreply.github.com>

@velo velo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default expression length guard stays unchanged, and the new system property is additive for users who need to tune or disable it explicitly. The ExpressionsTest additions cover the default, configured, and disabled cases, and the patch does not introduce a compatibility or security concern.

@velo velo merged commit 837dcd5 into OpenFeign:master Jun 19, 2026
3 checks passed
@velo velo mentioned this pull request Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MAX_EXPRESSION_LENGTH should not be fixed to 10000 but custom

2 participants