ruby-grape / ruby-grape/grape

declared(params) strips out default values from optional params before validation

Open
#1,145 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I have noticed that @permitted_params = declared(params) will set to null any optional param values when they have a default value set and they have not been passed in the call to an endpoint.

Ideally I think that optional param values should be included in the params returned by the declared method. But this is not what I am seeing.

In other words. If a param that is optional, that has not been passed in the call to the endpoint, but which has a default value specified in the param validation, in the endpoint the param will be in the params array and it will have the default value. However, when passing params through the declared method the returned array has the optional param but the default value has been lost and instead the value is null.

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 reproducing the declared(params) behavior described in the issue with an optional parameter that has a default value but is omitted from the endpoint call. Trace the parameter validation and declaration flow to find where the default becomes null. Done means the returned params retain the declared default and regression coverage demonstrates that behavior.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.