ruby-grape / ruby-grape/grape

Error response behaviour change in the JSON formatter

Open
#1,309 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug? discuss!
Dominant language
Ruby
Stars
10k
Forks
1.2k
Avg merge
14h 38m
Merged PRs (30d)
92

Description

Hi,

As I noted in this commit, there are some behavioural changes that are not very obvious and perhaps should either be reverted or documented.

Essentially, in ErrorFormatter::Json, the old behaviour (our app was on grape v0.10.1) was to:

  • pass on a Hash as it is, or;
  • wrap the error object (can be a string or array, etc - anything other than a hash) with { error: original_error_object }

The commit linked has unfortunately changed this behaviour to be:

  • wrap the error object with { error: original_error_object } ONLY IF the error object is a String, or;
  • anything else (a hash or an array, etc) will be passed on as they are

I have checked the test changes in the same commit, as well as the changelog, and I could not see any obvious reference to this behavioural change.

I would love to know more about the intention behind this change, and see we either revert or document this change accordingly.

Hope that makes sense. Thanks everyone!

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 ErrorFormatter::Json and the linked commit c20a9ad3ff81865898258d8bf92271048f1ff2b0. Compare the formatter test changes and changelog referenced in the issue with the old and current behavior. Done means the intended behavior is settled and the change is either reverted or documented accordingly.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.