ruby-grape / ruby-grape/grape

Issue with same param name in different given blocks

Open
#1,885 7 comments 1 reaction 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

        .....
        given name: ->(val) do
          val == 'name'
        end do
          requires :values, type: Array[String]
        end

        given name: ->(val) do
          val == 'another_name'
        end do
          requires :values, type: Array[Json]
        end
....

Seems like the check on the values param in the second block override the first. When both the blocks are executed in the same call the second check on values fails as invalid.
Sounds like a bug?

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 two given blocks in a small Grape API and trace how each values parameter validation is registered and applied. Done means both blocks can execute in the same call while preserving their distinct Array[String] and Array[Json] checks.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.