Error in AsValidator when using nested parameters
Open
Nobody has claimed this yet.
bug?
- Dominant language
- Ruby
- Stars
- 10k
- Forks
- 1.2k
- Avg merge
- 14h 38m
- Merged PRs (30d)
- 92
Description
Possible fix is to rescue all errors and re-raise as a Grape::Exceptions::Validation.
module Grape
module Validations
class AsValidator < Base
def initialize(attrs, options, required, scope, opts = {})
@renamed_options = options
super
end
def validate_param!(attr_name, params)
params[@renamed_options] = params[attr_name]
rescue StandardError => _e
raise Grape::Exceptions::Validation.new(
params: [@scope.full_name(attr_name)],
message: message(:invalid_format),
)
end
end
end
end
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 at Grape::Validations::AsValidator#validate_param! and inspect how nested parameters reach the assignment using @renamed_options. Confirm that failures there become Grape::Exceptions::Validation with the scoped attribute and invalid-format message, rather than an unrelated raw error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100