OpenFeign / OpenFeign/feign

Introduce 'decodeAll' option so response statuses != 2xx can be decoded as well

Open
#618 4 comments 12 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

proposal waiting for votes
Dominant language
Java
Stars
9.8k
Forks
1.9k
Avg merge
1d 2h
Merged PRs (30d)
41

Description

My team is using the Spring framework and RestTemplate to make client calls. We would like to move from RestTemplate to Feign. We currently use RestTemplate.exchange(...) to return a response object irrespective of the status (e.g. 2xx, 4xx, 5xx). So instead of dealing with try-catch exceptions, we interrogate the response object's status after the client call. To make marshaling life easier, our API contracts have a placeholders for both an error result and successful results -- thus we get marshaled responses for all statuses as well.

The default feign implementation (SynchronousMethodHandler) only allows 2xx and optionally 404 to be decoded... while all other statuses get an error thrown. We would like all response objects (regardless of the status) to get passed to the custom Spring Decoder and the client caller get back a ResponseEntity object.

This feature may solve other people's "issues" since it give users a centralized place (e.g. response interceptor) to deal with feign's Response objects. This centralized can return an object or fallback to the feign's original logic of throwing an exception.

This feature is similar to decode404.... but for all statuses.

@spencergibb any thoughts on this?

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 reading SynchronousMethodHandler and the existing decode404 behavior, then inspect how the custom Spring Decoder receives responses. Define how a decodeAll option should handle non-2xx statuses and preserve the original exception behavior when it is disabled; the feature is done when response objects can be returned for all statuses through the Spring Decoder.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.