Add a 'toBuilder' method, for enhancing defaulted Problems
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- java
- Domain
- api, backend-api-design
Research direction
Start by reading ProblemBuilder, Problem, and ConstraintViolationProblem, then inspect how the Jackson mixin preserves the violations field. Trace the ResponseBodyAdviceProblem use case described in the issue. Done should provide a way to add parameters while retaining the original problem type and its type-specific serialized data.
Written by the indexing model from the issue text.
Description
Detailed Description
We use the default error-handling provided by org.zalando.problem.spring.web.advice.ProblemHandling extensively in our application.
We also wish to add a trace ID parameter to all Problem responses. To do this, I thought to add a ResponseBodyAdvice<Problem> which copies the intercepted problem to a new ProblemBuilder, adds the trace ID, and returns the rebuilt problem to be the 'actual' response body.
However, in doing so, we end up breaking ConstraintViolationProblem, which no longer includes the violations field in the response JSON, because the Jackson mixin for violations is no longer used.
But ConstraintViolationProblem does not itself expose a way to set additional parameters.
I can get around this by subclassing ConstraintViolationProblem and exposing getParameters. But in future, there may be some other problem type whose type-specific data is 'lost'.
It would be great to have some way to clone a problem and retain its original type, while also providing additional parameters. Perhaps there's a way to do this and I just haven't found it yet?
Context
Adding extra information to framework-built Problem responses.
Your Environment
org.zalando:problem:0.27.0
org.zalando:problem-spring-web:0.27.0
- Dominant language
- Java
- Stars
- 951
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from zalando/problem
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Bug
Difficulty 3/5 1-2 days Newbie friendliness 65/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
-
Bug
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Feature
Difficulty 5/5 Over a week Newbie friendliness 25/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100