given arg_one require arg_two of array -> auto passes empty string to array when empty array is given
Open
Nobody has claimed this yet.
bug?
- Dominant language
- Ruby
- Stars
- 10k
- Forks
- 1.2k
- Avg merge
- 14h 38m
- Merged PRs (30d)
- 92
Description
desc 'Breaking Grape', security: [jwt: []], success: { code: 201, model: SomeRepresenter }
params do
with documentation: { param_type: 'body' } do
requires :arg_one, type: String, values: %w[one two three]
given arg_one: ->(type) { type == 'two' } do
requires :arg_two, type: Array[String], allow_blank: false
end
end
end
end
POST to that endpoint with { "arg_one": "two", "arg_two": [] }
and somehow the array will contain an empty string. Fails both with allow_blank false and allow_blank.
How does the empty string end up there?
How does it not fail when allow_blank false?
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.
Research direction
Start by reproducing the POST request against the params block using arg_one set to "two" and arg_two set to an empty array. Trace the handling of the conditional requires declaration and verify that an empty array does not gain an empty-string element and that allow_blank: false produces the intended validation result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100