feign icon indicating copy to clipboard operation
feign copied to clipboard

Truncated JSON header value with @Headers

Open daczczcz1 opened this issue 3 years ago • 12 comments

Observed on versions: 11.2, 11.4 Not reproducible on version: 10.1.0

When passing a JSON string as @Param to @Headers the string gets truncated.

Example:

{"some": "value", "other": "value"}

Gets truncated to:

{"some": "value", "other"}

Code to reproduce: https://github.com/daczczcz1/feign-bug-reproduction

daczczcz1 avatar Jul 21 '21 12:07 daczczcz1

We've run into this as well (using the RequestTemplate.header() method, but I'm guessing still hits the same templating logic as @Headers). Escaping the braces using percent encoding or double bracing ({{) doesn't help, as the content is not unescaped when it lands on the wire.

kppullin avatar Oct 18 '21 17:10 kppullin

The annotation based @Header should be different from the .header(...) method. A solution could be a .headerRaw(...) method.

vinz486 avatar Nov 22 '21 16:11 vinz486

This breaks our code. We're adding a custom JSON structure to a HEADER which now gets truncated. Please add another method as suggested above which adds a plain string as value without parsing

dagerber avatar Feb 24 '22 07:02 dagerber

Same problem here with the @RequestHeader annotation of spring-cloud-starter-openfeign library. The 3.1.1 version uses feign-core 11.8.

lavoiej1 avatar Apr 14 '22 15:04 lavoiej1

Ran into this today after upgrading from an older version to 11.8

JKomoroski avatar May 06 '22 15:05 JKomoroski

Any solution to this problem? We are blocked.

skpandey91 avatar May 13 '22 10:05 skpandey91

any update?

janson653 avatar Jun 22 '22 13:06 janson653

Blocked by the same problem. Any update or a workaround to resolve this please.

suryamurali1991 avatar Jun 23 '22 13:06 suryamurali1991

Hi @suryamurali1991 looking for volunteers to help fixing this issue.

velo avatar Jun 23 '22 23:06 velo

@velo I've seen the PR was close, any chance the issue gonna be attended soon?

SikoraAdam avatar Jul 07 '22 08:07 SikoraAdam

@SikoraAdam it's still waiting for someone to make the necessary changes. I'm willing to review it and get the release out of the door. Feel free to take a look on the comments we left at the PR and make the necessary changes

velo avatar Jul 07 '22 21:07 velo

I confirm that we are also impacted by this issue. I have temporarely forced our project to get the 10.12 version to make it work.

Samylots avatar Sep 07 '22 20:09 Samylots

Same problem for us. To sidestep it temporarily we're pulling in feign-core 11.0

<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-core</artifactId>
<version>11.0</version>
</dependency>

RussellTaylor83 avatar Sep 30 '22 09:09 RussellTaylor83

I ran a git bisect on this issue and narrowed it down to the following commit: f8ad8670e3dc73862f52eec475464a301e8c41cc

That commit did some much needed work. No way to revert it. The issue is not in the HeaderTemplate expand function, nor is it in the Expression or Simple Expression code. As far as I can see the RequestTemplate appears to be expanding the header template more than once. Resulting in an expression being expanded to JSON and then the Json being treated as a template and the Expression expansion going off the rails there.

I have a fork and commit with the duplication unit tests here: https://github.com/JKomoroski/feign/commit/0f686eb78b5fe40b6569eb7fa44e8ab1040e7a7e

Working on a sensible fix.

JKomoroski avatar Oct 02 '22 14:10 JKomoroski

Could you please let me know if this fix has been released?

xiaohundun avatar Apr 07 '23 02:04 xiaohundun

Could you please let me know if this fix has been released? Yes it was. https://github.com/OpenFeign/feign/releases/tag/12.0

JKomoroski avatar Apr 07 '23 02:04 JKomoroski

Could you please let me know if this fix has been released? Yes it was. https://github.com/OpenFeign/feign/releases/tag/12.0

Thank you.

xiaohundun avatar Apr 07 '23 03:04 xiaohundun