OpenFeign / OpenFeign/feign

Intercepted values are preserved from previous request on retry

Open
#2,376 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation feedback provided
Dominant language
Java
Stars
9.8k
Forks
1.9k
Avg merge
1d 2h
Merged PRs (30d)
41

Description

I'm using feign to call a backend API that needs a checksum of the request body as a query parameter. For this purpose I've implemented a RequestInterceptor which applies that query parameter to the request. Due to some issues with that API (f. ex. it being down for a few seconds) I also have a retrier applied, that retries the request in case it fails.

I just noticed an issue with that setup: the checkstum query parameter set in the previous request (that failed and should get retried) is not removed and the request is applied to the same request interceptor again. Due to the issue that there is no way to set a query parameter (only to append) which isn't clear from the method naming (query & appendQuery while both append to the query) the checksum is applied multiple times, causing the request to fail again as the backend (for some reason, don't ask me why) cannot handle multiple checksum parameters provided in the request:
<backend url>?checksum=1da6e6d858608e64d5e4a9798c589833&checksum=1da6e6d858608e64d5e4a9798c589833&checksum=1da6e6d858608e64d5e4a9798c589833&checksum=1da6e6d858608e64d5e4a9798c589833&checksum=1da6e6d858608e64d5e4a9798c589833&checksum=1da6e6d858608e64d5e4a9798c589833

For now I will just go ahead and remove the previous query parameter (calling query("checksum", List.of())), but it would be nice if the old request without the intercepted values could be passed to the retrier to prevent these issues (not calling the interceptors again might be another solution, however, maybe there are apis that need f. ex. a time-based checksum that requires re-computing the checksum). Another solution might be to just add setQuery/setHeader methods to override the previous query/header value explicitly.

I didn't validate yet, but I am pretty sure that issue also applies to headers.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how RequestInterceptor is applied through the retrier, then inspect the query and appendQuery APIs and the corresponding header handling. Determine how a retry can avoid accumulating intercepted query parameters or headers while still allowing values such as time-based checksums to be recomputed. Done means repeated retries no longer produce duplicate intercepted values and the behavior is covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.