Skip to content

treat invalid expression value modifier as a literal#3437

Merged
velo merged 1 commit into
OpenFeign:masterfrom
alhudz:expression-modifier-literal
Jun 23, 2026
Merged

treat invalid expression value modifier as a literal#3437
velo merged 1 commit into
OpenFeign:masterfrom
alhudz:expression-modifier-literal

Conversation

@alhudz

@alhudz alhudz commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Values supplied through @HeaderMap are parsed as URI templates, so a value that contains {...:...} is treated as an expression and the text after the : is compiled as a regular expression in Expression. A value like {range:[1:10} (brackets plus a colon, easy to hit with JSON-ish header data) is not a valid pattern, so Pattern.compile throws an uncaught PatternSyntaxException from Expressions.create and the whole request fails to build. Reported in #2739.

Expressions.create already returns null for chunks it cannot validate as an expression, and Template.parseFragment keeps those as literals. The fix catches PatternSyntaxException there and falls back to that same literal path, so a malformed value modifier is emitted verbatim instead of aborting expansion. Keeping the guard in the parser covers every template type (header, query, uri) and leaves valid {name:regex} expressions untouched.

@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.

This keeps the parser behavior nicely contained: invalid regex modifiers now fall back to the existing literal path, and the tests cover both header-map expansion and valid modifiers. Looks good to me.

@velo velo merged commit 5cd6f57 into OpenFeign:master Jun 23, 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.

2 participants